Using the. htaccess file to achieve URL static using the. htaccess file to achieve URL static problems are described as follows: I want to implement the following functions: non-static URL: inetassistant. comtasks. php? Id28 & amp; titleWordpress static URL: inetassistant. comtasks28Word static URL using the. htaccess file
Static URL using the. htaccess file
The problem is described as follows:
I want to implement the following functions:
Non-static URL: http://inetassistant.com/tasks.php? Id = 28 & title = Wordpress
URL after static implementation: http://inetassistant.com/tasks/28/Wordpress.html
1.
Put the. htaccess file under the root directory of the website. The content is as follows:
Options-Indexes
RewriteEngine On
RewriteBase/
RewriteRule ^/tasks/([0-9] +)/([a-za-z?##.html $/tasks. php? Id = $1 & title = $2
The link in the PHP file is written as follows:
Wordpress
However, enter
Http://www.xxx.com/tasks/28/wordpress.htmlcannot access
Http://www.xxx.com/tasks.php/28/wordpress.html#can access (but cannot display the corresponding content)
2. the other situation is:
RewriteRule ^/tasks. php/([0-9] +)/([a-za-z?##.html $/tasks. php? Id = $1 & title = $2
Write Wordpress like this
When I click a link, I cannot configure http://www.xxx.com/tasks.php/28/wordpress.html, but there is no corresponding content,
Note: Wordpress is actually dynamically retrieved from the database for the purpose of looping the output title and clicking the title to display the corresponding article content.
Please help me to find out where these two problems occur
------ Solution --------------------
RewriteEngine On
RewriteBase/
RewriteCond % {REQUEST_URI} ^/tasks/([0-9] +)/([A-Za-z] +) \. html $
RewriteRule ^. + $ tasks1.php? Id = % 1 & title = % 2 [L]
What configuration is added to my apache environment?
When tasks and my file names are the same, they won't match. I just need to replace tasks. php with task1.php.
Put this in the folder where task1.php is located.