About Apache Server rewrite

Source: Internet
Author: User
My goal is to enter the URL in the address bar:
Http://localhost/project/ShortURL/index.php/149Ui3
Automatically rewritten as
Http://localhost/project/ShortURL/index.php?controller=jump&method=jemp&code=149Ui3
Apache adds the following configuration (apache2.conf):
 
  
   
       # Turn on rewrite engine     Options +followsymlinks     rewriteengine in     # more rules below     rewriterule ^ index.php/(. *) $ index.php?controller=jump&method=jump&code=$1 [QSA]
 
  

But always can not jump, ask how should be properly configured it.


Reply to discussion (solution)

1.httpd.conf The rewrite module is turned on correctly
2. Is the configuration file you wrote valid?

I am under Ubuntu, did not find the httpd.conf file, the main configuration file only apach2.conf, and now the configuration is this.
1. In the/var/www/project/shorturl directory, create a. htaccss file with the following contents:

# Turn on rewrite engineoptions +followsymlinksrewriteengine on# more rules Belowrewriterule ^index.php/(. *) $ index.php?c ontroller=jump&method=jump&code=$1 [QSA

2. The following configuration was made in apach2.conf:
 
  
   
      Options followsymlinks    allowoverride all    Require all granted
 
  

No other configuration is done. Now the problem is this:
The problem now is that each input http://localhost/project/ShortURL/index.php/149Ui3 will show no CSS style control http://localhost/project/ShortURL/ index.php content (address bar or http://localhost/project/ShortURL/index.php/149Ui3), cannot jump to http://localhost/project/ShortURL/ Index.php?controller=jump&method=jemp&code=149ui3 this address.

1.httpd.conf The rewrite module is turned on correctly
2. Is the configuration file you wrote valid?


Now, as shown in the building, sorry to reply wrong.

Problem solved, summed up:
Problem Description:
My goal is to enter the URL in the address bar:
Http://localhost/project/ShortURL/index.php/149Ui3
Automatically rewritten as
Http://localhost/project/ShortURL/index.php?controller=jump&method=jump&code=149Ui3
Solution Solutions
1. Make the following configuration in apach2.conf:

Options FollowSymLinks
AllowOverride All
Require all granted

2. In the/var/www/project/shorturl directory, create a. htaccss file with the following contents:
# Turn on rewrite engine
Rewriteengine on
# More Rules below
Rewritebase/
Rewriterule ^index.php/(. *) $ http://localhost/project/ShortURL/index.php?controller=jump&method=j ump& code=$1 [l,r=301]
written in the last
It's time to read more documents, thanks to open source China crazy snail offers ideas.

  • 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.