.htaccess url: rewrite is not working at local host Xampp - .htaccess

My current url is
http://localhost/www.zeeshan.com/user.php?name=zeeshan06
I want to display my url as
http://localhost/www.zeeshan.com/user/zeeshan06
I use the following code but it not working
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Options +FollowSymlinks
RewriteBase /
RewriteRule ^user/(.*)user.php?name=$1 [R]
Please help me to solve my problem. Thanks.

If you place this .htaccess inside the folder www.zeeshan.com:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /www.zeeshan.com/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^user/([^/]+)$ user.php?name=$1 [NC,L]
And access the URL:
http://localhost/www.zeeshan.com/user/zeeshan06
It should lead you to:
http://localhost/www.zeeshan.com/user.php?name=zeeshan06

// http://localhost/Milan_Practice/Milan_Mvc/routing.php?name=about
RewriteEngine On
Options +FollowSymLinks
RewriteCond %{THE_REQUEST} ^(GET|HEAD|POST)\ /Milan_Practice/Milan_Mvc/routing\.php\?name=([^&]+)
RewriteRule ^ /Milan_Practice/Milan_Mvc/routing/%2/%3?%4 [L,R=301]
RewriteRule ^/?Milan_Practice/Milan_Mvc/routing/([0-9]+)/(.*)$ /Milan_Practice/Milan_Mvc/routing.php?name=$1 [L,QSA]

Related

301 Redirect Dynamic URL

OK so I have the following as part of the URL: /user/26872-essi/
and I'm going to final URL of /essi/
I currently have:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^user\/([0-9]+)\-.+[/]?$ /user.php?user_id=$1
So I tried:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^user\/([0-9]+)\-.+[/]?$ /$2/ [R=301,L]
RewriteRule ^(((?!\.|\/).){1,})\/?$ /user.php?username=$1
It doesn't seem to be passing the variable in. Any ideas what I could be doing wrong?
You may use these rules in your site root .htaccess:
RewriteEngine On
RewriteRule ^user/\d+-([\w-]+)/?$ /$1/ [R=301,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/?$ user.php?username=$1 [L,QSA]

rewrite not working with godaddy after several attempts

I Tried every possible solution suggested , still my pages are completely unaffected
My URL
http://MyDomain/WCOM/Flatsome/pages/about-us/
is showing 404 on godaddy server but working find on WAMP ..
I have Tried following htaccess .
1.
DirectoryIndex index.php
AddDefaultCharset utf-8
RewriteEngine on
Options +FollowSymlinks -MultiViews -Indexes
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) /$1.htm [L]
2.
#Fix Rewrite
Options -Multiviews
# Mod Rewrite
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) /$1.htm [L]
Nothing is working .. What Can I do More ?

Masking an url in rewrite

I have a url
www.abc.com/description.php?id=123035
when I write a url like
abc.com/123035/Four_Seasons_Hotel_Istanbul_at_Sultanahmet
I want to get the result. Rewrite won't see "Four_Seasons_Hotel_Istanbul_at_Sultanahmet" will see only id and will work.
How can that be done?
I have tried this
Options +FollowSymlinks
# Prevent Directoy listing
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/.]+)$ description.php?id=$1 [QSA]
</IfModule>
But it doesn't work.
You can use this rule:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([0-9]+)/[^/]+/?$ /abc/description.php?id=$1 [L,QSA]

.htaccess remove index.php and hide parameter name

I have the following URL
www.site.com/index.php?key=blah
I want to make it like the following using .htaccess
www.site.com/blah
How can i achieve this using .htaccess?
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+?)/?$ /index.php?key=$1 [L,QSA]
it is what i'm using on my website, it works on local too.
Options -Indexes
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?key=$1 [L]
</IfModule>

htaccess url shortening works locally not on server

I wonder if anyone can take a look at this htaccess and tell me why it should work on a localhost but not on server
Options +FollowSymlinks
RewriteEngine On
RewriteBase /subdirectory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^news(.*)$ news.php?q=$1 [L,QSA]
RewriteRule ^view/([^/]+)/([^/]+).html /view.php?content_id=$1&content_id=$2 [NC]
Try to remove RewriteBase /subdirectory or rename it to RewriteBase /.

Resources