I have url like
http://example.com/index.php/allmodels/Samsung-mobiles_80
and i want to convert into
http://example.com/index.php/allmodels?st=Samsung-mobiles_80
I am using following code
Options -Indexes
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^allmodels/(.*)$ /allmodels?st=$1 [NC,L]
but this code is not working.
All the setting is correct I have tested and htaccess is working.
When i used following code that is working but above given code is not working.
Options -Indexes
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$1 [NC,L]
Related
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
I have this rewrite rule in my htaccess script, but whenever i do a var_dump on $_GET it's empty, like the values from the url are not read in PHP.
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^index.php/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?app=$1&page=$2&category=$3 [L]
</ifModule>
Example of url: .../index.php/main/featured/1
How can one fix this problem?
Thank you!
I believe these two conditions:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
are not met as your URL is /index.php/main/featured/1. At least it did not work for me either. Can you either remove index.php part both from RewriteRule and your URL, making .htaccess:
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?app=$1&page=$2&category=$3 [L]
</ifModule>
and navigating to URL /main/featured/1 or if you really need the index.php part, then uncomment/remove these conditions:
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
and continue using /index.php/main/featured/1 URL.
I have been working on localhost, and my htaccess file is
Options +FollowSymLinks
Options -Indexes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]
after adding the htacces code,the url
localhost/movies/news.php
works
localhost/movies/news
also works but
localhost/movies/news/
doesn't work. It shows "Internal Server Error".How to make it work with slash and without slash.
You an try this code:
Options +FollowSymLinks -MultiViews
RewriteEngine On
# Internally forwards movies/news/ to movies/news.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
The problem is when you add the slash you have news/.php and this is not working.
A better solution is to rewrite to a GET variable something like this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php?url=$1 [L]
Then you can filter the GET variable in your script and include the file or content you need.
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]
I am looking for a way to access to:
http://myurl.com/?file=random_token
with
http://myurl.com/random_token/
I already read about mod_rewrite in the .htaccess but I don't know how to setup the pattern.
I tried this:
Options +FollowSymLinks
RewriteEngine on
RewriteRule /(.*)/$ /index.php?file=$1
It would be nice if you can help me.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/$ /?file=$1 [L]
Try this
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCOnd %{REQUEST_FILENAME} !-d
RewriteRule /?([a-z-]+) index.php?file=$1 [L,QSA]