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]