I am having a tough time to understand how mod_rewrite works.
I have a url like this:
www.example.com/store/index.php?categ=headbands
And I want to make it look like this:
www.example.com/store/headbands
I am trying this, but not working:
RewriteEngine on
RewriteBase /store/
RewriteRule ^index/([^/\.]+)/?$ $1 [L]
And I confirmed the mod_rewrite is activated with a random example I found.
Any suggestions?
Thanks!
Try This one
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^/store/(.*)$ /store/index.php?categ=$1 [NC,L]
OR
Put the .htaccess file inside the "store" directory with following code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?categ=$1 [NC,L]
Related
I am trying to change my url to try to stop it from showing the language folder in the url for example:
change from
www.site.com/en
change to
www.site.com
so I am looking to remove the
en
from the url but still accessing that directory. This is what I have so far but it does not seem to do the trick:
RewriteEngine on
RewriteBase /mysite/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .+ en=$0 [L,QSA]
Thank you.
This should do it:
RewriteEngine on
RewriteBase /mysite/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ en/$1 [L,QSA]
I have a very simple piece pf code. I want to enter some word in URL and wants that it should stay on the same page.
My index.php file is
<?php
echo "sample test";
?>
My htaccess file is
RewriteEngine on
RewriteCond % {REQUEST_FILENAME}!-d
RewriteCond % {REQUEST_FILENAME}!-f
RewriteRule ^(.*)$index.php?url=$1[L,QSA]
Both file are placed in the kite folder of wamp directory.
When I type localhost/kite then the index page appears. But when i write something more after kite for example localhost/kite/about then it says requested url is not found.
I have turned on all rewrite_module in wamp.
The following is correct and working. You were almost there, your spacing was just off a little.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?url=$1 [L,QSA]
You can try like this
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /kite/index.php/$1 [L]
or
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
I'm trying to rewrite a url that looks like http://example.com/View/(random_text) to take the user to http://example.com/View/site.php?site=(random_text)
This is what I am ussing so far:
Options -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^View/(.+)$ View/site.php?site=$1 [NC]
Any help is appreciated, thanks.
Try this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)/View/(.+)$ /View/site.php?site=$2 [L,R=301]
If the "View" directory is in your webserver's root directory, then add just the single forward slash as above. Else add the path to the view directory like below:
RewriteRule ^(.*)/View/(.+)$ /path_to_view_directory/View/site.php?site=$2 [L,R=301]
A very common problem, but couldn't fix the issue.
I want
http://website.de/page.php?module=helios
into
http://website.de/page/helios
I have tried lots of .htaccess code like this one, but still page sends to 404.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ page.php?module=$1
Please provide some suggestions.
Try this rule in your site root .htaccess:
Options -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^page/([^/]+)/?$ page.php?module=$1 [L,NC,QSA]
Try...
RewriteRule ^page/([^/]*)/$ /page.php?module=$1 [L]
Use this use your base path
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^page/(.*)$ page.php?module=$1
Can't figure out what I'm doing wrong.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)\.php$ detail.php?name=$1 [NC,QSA,L]
RewriteRule ^(.+)/directory/\.php$ detail2.php?name=$1 [NC,QSA,L]
The first RewriteRule should redirect anything (ending on php like domain.com/product1.php) from the root domain to detail.php (it can not affect things like domain.com/contact.php)
A 2nd RewriteRule should redirect anything from domain.com/directory/product-b1.php to detail2.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /foldernamehere/index.php/$0 [PT,L]
paste this code in your .htaccess file it will resolve your problem