2

I'm writing my very first .htaccess file and although I've learnt a lot already I have one thing that I'm struggling with.

I have a CMS that generates pages based upon a variable called "filename" that's passed through my URL for example... index.php?filename=about.htm

So I only have one real file... index.php

I would like "index.php?filename" to not appear so all URL's look normal like www.example.com/about.htm even though the "filename" query string is still being passed.

I hope I've made sense and this is possible... Thanks guys!

2 Answers 2

1

Want to rewrite /$var to /index.php?filename=$var? Try to paste this into the .htaccess file:

Options +FollowSymlinks
RewriteEngine on

RewriteCond %{REQUEST_URI} ^/index\.php$
RewriteCond %{QUERY_STRING} filename=([a-z0-9-_])
RewriteRule ^(.*) /index.php?filename=%1
Sign up to request clarification or add additional context in comments.

Comments

0
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?filename=$1 [L,QSA]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.