1

I have been working on an .htaccess file. The url I started with was, www.example.com/index.php?page=pagetitle. I want the Link to only show www.example.com/pagetitle.

So far the only thing in my .htaccess file removes the index.php.

Options -MultiViews

RewriteEngine on

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.(php|html?)
RewriteRule ^ /%1 [R=301,L]

Any help would be greatly appreciated, I sadly don't have the knowledge to create these codes on my own.

Thank you in advance.

I will also be editing this question as I figure more of this out, from support of other people etc.

1 Answer 1

2

You can try these rules:

Options -MultiViews

RewriteEngine on

# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?page=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=302,L]

# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ index.php?page=$1 [L,QSA]
Sign up to request clarification or add additional context in comments.

1 Comment

It looks like it works, thank you very much! I'll accept you answer when it lets me :-)

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.