-2

Basically, I was wondering if I could take a url like:

http://tai.tskynet.com/?id=book

and rewrite it to

http://tai.tskynet.com/book/

http://tai.tskynet.com/book

like a "fake" folder.

What should I write?

  • Possible duplicate of [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](https://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) – Croises Nov 20 '18 at 14:01

1 Answers1

0

First, you have to make sure that your rewrite_module and dir_module is enabled in apache. Then check your httpd.conf file to make sure that these lines exist:

LoadModule rewrite_module modules/mod_rewrite.so
LoadModule dir_module modules/mod_dir.so

Then set the value for DirectoryIndex to include the target file (index.php as example)

<IfModule dir_module>
  DirectoryIndex index.php ...
</IfModule>

Here is the .htaccess file:

RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|assets|uploads|cloudfront\.php)
RewriteRule ^(.*)$ index.php/$1 [L]

This would forward your URI values to the target file [index.php] then process it there. In the example, robots\.txt|assets|uploads|cloudfront\.php will not be forwarded to index.php and instead will be treated as normal directory requests.

claw68
  • 374
  • 3
  • 10