I want to rewrite my url from http://xyz.edu/profile.php?name=gavin to http://xyz.edu/gavin.html
Sample code:
RewriteRule ^profile\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ profile.php?compname=$1 [L]
Well it's about the same rules you already have. Try this and let me know how it works for you.
RewriteEngine On
RewriteRule ^profile\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.html$ profile.php?compname=$1 [L]
Related
I'm totally newbie in htaccess and it has been a month since I'm trying to rewrite this one URL but no luck. Tried searching on the internet a lot and tried out the method that worked for others but not working for me unfortunately.
The htaccess rule for my dynamic page works, for example site/index.php?viewpage=application shows up as site/application
What I'm struggling to do is, I'm trying to rewrite the following url: site/application?name=abcd&date1-2-3&version=5.0 to site/application/abcd/1-2-3/5.0
This is my htaccess code
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?viewpage=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /application?name=$1&date=$2&version=$3 [L]
Try this :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} !name
RewriteRule ^([^/]+)$ index.php?viewpage=$1 [L]
RewriteRule ^(.+)/(.+)/(.+)/(.+)$ /$1?name=$2&date$3&version=$4 [L]
If you want the last line to be limited with application only , replace with this :
RewriteRule ^application/(.+)/(.+)/(.+)$ /application?name=$1&date$2&version=$3 [L]
UPDATE CODE:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} !name
RewriteRule ^([^/]+)$ index.php?viewpage=$1 [L]
RewriteRule ^(.+)/(.+)/(.+)/(.+)$ index.php?viewpage=$1?name=$2&date$3&version=$4 [L,NE]
How to rewrite this links?
from
http://www.example.com/websitedevelopment.php?lan=en
to
http://www.example.com/websitedevelopment/en
and
http://www.example.com/index.php?lan=en
to
http://www.example.com/en
thanks..
Try with below,
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^websitedevelopment/en$ websitedevelopment.php?lan=en [L]
RewriteRule ^en$ index.php?lan=en [L]
I want to change page url with .htaccess my url is 'page.com/web/' and I want to have just page.com. Could you give me htacces code. for example
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /?$1 [L]
Try this :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ web/$1 [NC,L]
I can't figure out how to rewrite this URL
http://localhost/site/page.php?id=[pagetitle]
to
http://localhost/site/page/title
and
for user profiles
http://localhost/site/profile.php?username=username
to
http://localhost/site/profile/username
This is the code I'm using:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^profile(.*)$ profile.php?username=$1
RewriteRule ^(.*)$ page.php?title=$1
this will rewrite the input localhost/site/page/title to loacalhost/site/page.php?id=[pagetitle]
RewriteRule ^localhost/site/(.+)$ site/page.php?id=$1
RewriteRule ^localhost/site/profile/(.+)$ site/profile.php?username=$1
This should work
RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?username=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ profile.php?username=$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^profile/(.*)$ profile.php?username=$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^page/(.*)$ page.php?title=$1
assumed that the .htaccess at the /site/ directory
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . content.php [L]
RewriteRule !((inquiry|gallery)|(.*)\.(jpg|png|JPG|PNG|gif)$) content.php?q=$1 [L,QSA]
I am trying but it shown page not found
Try reversing the rules:
RewriteEngine on
RewriteRule !((inquiry|gallery)|(.*)\.(jpg|png|JPG|PNG|gif)$) content.php?q=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . content.php [L]