Apache Server allows URL rewrite rule by simply placing a file called .htaccess under the FTP directories. The Rewrite Rules will override its parent one if there is any. However, you could set the following in sub-folder’s <em.htaccess. to explicitly allow using parents’ .htaccess.
RewriteOptions inherit
After installation of WordPress, it will generate a .htaccess under the root directory of the blog. Take this blog for example, the following is the default content generated by WordPress.
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /acm/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /acm/index.php [L] </IfModule> # END WordPress
Comments start as hash. IfModule checks if the rewrite-module is enabled. ^index\.php$ – [L] prevents requests for index.php from being rewritten, in order to avoid infinite loops. If the request is for index.php the directive does nothing – and stops processing rules [L] i.e. L – Last. RewriteCond specifies that if the requested is not a real file or not a real directory, all will be redirected to index.php, which can obtain the $_SERVER[‘REQUEST_URI’] and it calls the correct code for rendering the page the user requested.
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/?(.*)$ /index.php?id=$1 [L] </IfModule>
The above line RewriteRule ^/?(.*)$ /index.php?id=$1 [L] is usually used to translate the URL like https://steakovercooked.com/xyz to https://steakovercooked.com/index.php?id=xyz.
–EOF (The Ultimate Computing & Technology Blog) —
loading...
Last Post: PHP Rot47 Function (str_rot47)
Next Post: New site and Three pages