Apache server rewrite-php Tutorial

Source: Internet
Author: User
For apache server rewrite, I aim to enter the url in the address bar:
Http: // localhost/project/URLs/index. php/149Ui3
Automatically rewrite
Http: // localhost/project/dynamic URL/index. php? Controller = jump & method = jemp & code = 149Ui3
Add the following configuration in apache (apache2.conf ):
 
       # Turn on rewrite engine     Options +FollowSymlinks     RewriteEngine on     # More rules below     RewriteRule ^index.php/(.*)$ index.php?controller=jump&method=jump&code=$1 [QSA]
 

But it cannot be redirected. how can I configure it correctly.


Reply to discussion (solution)

1. is the rewrite module enabled correctly in httpd. conf?
2. is the configuration file you wrote valid?

I did not find the httpd. conf file in ubuntu. The main configuration file is only apach2.conf, and the current configuration is like this.
1. create a. htaccss file in the/var/www/project/upload URL directory as follows:

# Turn on rewrite engineOptions +FollowSymlinksRewriteEngine on# More rules belowRewriteRule ^index.php/(.*)$ index.php?controller=jump&method=jump&code=$1 [QSA

2. make the following configuration in apach2.conf:
 
      Options FollowSymLinks    AllowOverride ALL    Require all granted
 

The problem is as follows:
The problem is that http: // localhost/project/upload URL/index is entered each time. php/149Ui3 will display http: // localhost/project/invalid URL/index without css style control. php content (the address bar is http: // localhost/project/URL/index. php/149Ui3), cannot jump to http: // localhost/project/upload URL/index. php? Controller = jump & method = jemp & code = 149Ui3

1. is the rewrite module enabled correctly in httpd. conf?
2. is the configuration file you wrote valid?


As shown in #2 floor. sorry for the error.

The problem is solved. to sum up:
Problem description:
My purpose is to enter the url in the address bar:
Http: // localhost/project/URLs/index. php/149Ui3
Automatically rewrite
Http: // localhost/project/dynamic URL/index. php? Controller = jump & method = jump & code = 149Ui3
Solution
1. make the following configuration in apach2.conf:

Options FollowSymLinks
AllowOverride ALL
Require all granted

2. create a. htaccss file in the/var/www/project/upload URL directory as follows:
# Turn on rewrite engine
RewriteEngine on
# More rules below
RewriteBase/
RewriteRule ^ index. php/(. *) $ http: // localhost/project/invalid URL/index. php? Controller = jump & method = j ump & code = $1 [L, R = 301]
Conclusion
I have to read more documents when it's okay. thanks to the idea provided by the open-source Chinese crazy snail bait.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.