0
RewriteEngine on Rewriterule ^(.*).htm $1.php 

This works fine when i try to access every php page

But how could i make it RewriteRule ^/somepage $ /somepage.php (its not working )

if the page is about.php the url should be about/ (directory type)

0

3 Answers 3

2

Alternatively to Jan's answer:

RewriteRule ^/about/?$ /about.php 

will rewrite it whether they remember the final / or not.

Sign up to request clarification or add additional context in comments.

Comments

1

If you want to use the rule in a .htaccess file, you need to remove the local path prefix from the pattern as it is removed before testing the pattern. In case of the root directory that is the /. So try this:

RewriteRule ^somepage/$ /somepage.php 

And for arbitrary path segments:

RewriteRule ^([^/]+)/$ /$1.php 

Comments

0
RewriteRule ^/about/$ /about.php 

1 Comment

I don't think Lixon wants to add a rule for every single page.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.