Remove page id from url with mod_rewrite

I want to go from www.site.com/page.php?url=string.html to www.site.com/string.html

My .htaccess looks like this:

RewriteEngine On

RewriteRule ^([a-zA-Z0-9-/]+).html$ page.php?url=$1
RewriteRule ^([a-zA-Z0-9-/]+).html/$ page.php?url=$1

But it does not do anything.

Answers


Try the following rewrites:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET\ /cms/page\.php\?url=([^\s&]+) [NC]
RewriteRule ^page\.php$ /%1? [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*\.html$ /cms/page.php?url=$0 [QSA,L]
EDIT

Since the page is inside /cms directory, updated the rules to reflect the same.


Need Your Help

.NET 4, how to execute dynamic vb code like windows workflow 4 does

dynamic .net-4.0 workflow-foundation workflow-foundation-4

Just curious how Windows Workflow 4 executes vb code. Can I use the same techique to execute vb.net code at run-time?

Reallocating memory via "new" in C++

c++ memory-management new-operator

Quick question regarding memory management in C++