Reputation: 71
The CMS I have created uses a variable called "filename" that's passed via the URL to generate pages.
My typical URL looks like this:
/index.php?filename=about.html
I would like to amend my URL's to look like this:
/about.html
Of course I would also like my URL when first visiting the page to look like this:
/index.html
(Replace .php
with .html
)
I'm new to using the .htaccess
file but would really like to amend my URL's to look this way, I hope that's possible. Thanks guys!
Upvotes: 0
Views: 72
Reputation: 3088
Try this:
Options +FollowSymLinks -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([0-9a-zA-Z\-]+.html)$ index.php?filename=$1 [L,NC]
</IfModule>
For example, if I run: http://so.localhost/This-is-your-page.html
result of var_dump($_GET);
is:
array (size=1)
'filename' => string 'This-is-your-page.html' (length=22)
I hope I helped.
Upvotes: 1