1

I want to remove the .php from the url through htaccess file. for example home.php to home I'm using the following rewrite rule in htaccess file.

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

and also I want to rewrite the url. for example

/detail.php?ca=38&title=rewrite uri sample 

to

detail/article/38/rewrite uri sample 

2 Answers 2

1

I try search to the entire www, then I have an answer..

RewriteEngine On Options +FollowSymLinks -MultiViews RewriteRule ^article/([0-9]+)/?$ detail.php?ca=$1 [NC,L] RewriteRule ^article/([0-9]+)/([A-Za-z0-9-]+)/?$ detail.php?ca=$1&title=$2 [NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for Abdulla that I get the rewrite .php, and thanks to Starkeen to edit my question
0

Use

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] 

For GoDaddy

Options +MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] 

2 Comments

Your answer is incomplete, he also wants to remove query strings from urls.
If I can adding some question, can I change " " with "-" example detail/article/38/rewrite uri sample to detail/article/38/rewrite-uri-sample and how I get variable "38" and "rewrite uri sample" with simple php :) thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.