0

I have a website where i have pages like:

domain.com/?p=settings

domain.com/?p=daily

And i am looking for rewrite that ?p= part, so it would be like

domain.com/settings

So far i have tried to add this to htaccess files:

RewriteRule ^([^\.]+)$ $1?p= [NC,L]

but it did not worked.

Also I have tried look from Google but could not find any.

I have tried other RewriteRule's but they did not work either.

Mohammad Yusuf
  • 16,554
  • 10
  • 50
  • 78
Jaska Jokela
  • 29
  • 1
  • 1
  • 7
  • You can rewrite your url from IIS level. refer this link, may help you http://stackoverflow.com/questions/4410067/iis-url-rewrite-and-web-config – Devanathan.S Jan 04 '17 at 13:57
  • Possible duplicate of [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](http://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) – Croises Jan 04 '17 at 14:06

2 Answers2

0

RewriteRule does not include query string. It is available as a separate variable enter link description here

The Pattern will initially be matched against the part of the URL after the hostname and port, and before the query string (e.g. "/app1/index.html"). This is the (%-decoded) URL-path.

So the following won't work.

RewriteRule ^([^.]+)$ $1?p= [NC,L]

You need something like

RewriteCond %{QUERY_STRING} ^(\w+)=(\w+)$
RewriteRule ^/ %2?

Checkout Apache Mod ReWrite Wiki and scroll down to "Making the Query String Part of the Path"

bhantol
  • 9,368
  • 7
  • 44
  • 81
0

You were close with your attempt, you need to use this in your .htaccess:

RewriteEngine On
RewriteRule ^([^/]*)$ /?p=$1 [L]

Make sure to clear your cache before testing this.

Joe
  • 4,877
  • 5
  • 30
  • 51