One. htaccess method is troublesome. thank you very much!

Source: Internet
Author: User
One. htaccess method for help. thank you very much for your advice !! The original link format is xxx.com/index.php? Id = xxx (ID value contains A-Z, a-z, 0-9) to convert to xxx.com/xxx (directory format) where id = index is the home page root directory PS: I am using some function station calls of Wordpress to create a small site for help. thanks for your advice on writing htaccess !!
The original link format is xxx.com/index.php? Id = xxx (ID value contains A-Z, a-z, 0-9)
To convert to xxx.com/xxx (directory format)
The id = index is the root directory of the home page.

PS: I am using some function station calls of Wordpress to create a small site. because I do not know much about URL rewriting, I am exploring and adding a part of it on the basis of WP's htaccess.

Problem:
1. do not display the 404 page (even if the HTTP header information returns 404 and the 404 page is set in htaccess)
2. non-existing directory (undefined Directory, for example: xxx.com/test/123) the HTTP header returns 200 normal access.
3. "/" problems, such as: xxx.com/123 is not equal to xxx.com/123/

I wrote it like this:

HTML code
  RewriteEngine OnRewriteBase/RewriteRule ^123 /? $ Index. php? Id = 123 [L] RewriteRule ^ test /? $ Index. php? Id = test [L] RewriteRule ^ $ index. php? Id = index [L] # The above is the rule I added myself. I use these three variables and write them directly. # The following are WP rules. RewriteCond % {REQUEST_FILENAME }! -FRewriteCond % {REQUEST_FILENAME }! -DRewriteRule./index. php [L]


------ Solution --------------------
That rewrite is written in regular expressions. you can see it in the manual.
------ Solution --------------------
RewriteEngine On
RewriteBase/

RewriteCond % {REQUEST_FILENAME }! -F
RewriteCond % {REQUEST_FILENAME }! -D

RewriteRule ^ (.*)/? $ Index. php? Id = $1 [L]

RewriteRule./index. php [L]

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.