0

Good days guys, I need your help with this url rewrite.

The are two rewrites I want to do.

1) I want to take out .php from the url even though my files is saved as .php

2) I want to rewrite the url below

If you can help me. It will be lovely. Thanks

5
  • 3
    But your desired URL has no logic ... Commented Jul 30, 2013 at 8:56
  • Explain yourself to me please @Mihai Commented Jul 30, 2013 at 8:59
  • Sef is a parameter and so is pid and you want ?Sef=shoes/pid/3 .... shoes/pid/3 becomes a variable to Sef parameter ... it has no logic ... how would you know which is which ? Commented Jul 30, 2013 at 9:11
  • @mihai I see your point. But is they no way I can use php to change it? Commented Jul 30, 2013 at 9:22
  • @Jessica check anub's answer should work just fine for removing the extension. Commented Sep 25, 2013 at 9:55

1 Answer 1

1

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your DOCUMENT_ROOT/.htaccess file:

Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / ## hide .php extension # To externally redirect /dir/foo.php to /dir/foo RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php[\s?] [NC] RewriteRule ^ %1 [R=301,L] # To internally forward /dir/foo to /dir/foo.php RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{DOCUMENT_ROOT}/$1.php -f RewriteRule ^(.+?)/?$ /$1.php [L] 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.