I have the following lines in my .htaccess
Options +FollowSymlinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ seo.php?p=$1 [L]
RewriteRule ^seo/site:(.*)$ seo.php?p=seo&domain=/$1&status=seo [QSA]
RewriteRule ^seo/(.*)$ seo.php?p=seo&domain=/$1&status=seo [L]
RewriteRule ^admin/page:(.*)$ seo.php?p=admin&page=/$1 [L]
RewriteRule ^webagent/page:(.*)$ seo.php?p=webagent&page=/$1 [L]
RewriteRule ^setlang:(.*)$ seo.php?setlang=/$1 [L]
RewriteRule ^(.*)/setlang:(.*)$ seo.php?p=/$1&setlang=/$2 [L]
</IfModule>
The problem is that only first Rule works normal. it takes pages from currently defined folder in php
When i try to open
seo/domain.com
it doesn't work but when i open
seo.php?p=seo&domain=domain.com&status=seo
works very well.
Where i go wrong with this .htaccess file.
Have your rules like this:
Options +FollowSymlinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# skip all files and directories from rewrite rules below
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^seo/site:(.*)$ seo.php?p=seo&domain=/$1&status=seo [L,QSA]
RewriteRule ^seo/(.*)$ seo.php?p=seo&domain=/$1&status=seo [L,QSA]
RewriteRule ^admin/page:(.*)$ seo.php?p=admin&page=/$1 [L,QSA]
RewriteRule ^webagent/page:(.*)$ seo.php?p=webagent&page=/$1 [L,QSA]
RewriteRule ^setlang:(.*)$ seo.php?setlang=/$1 [L,QSA]
RewriteRule ^(.*)/setlang:(.*)$ seo.php?p=/$1&setlang=/$2 [L,QSA]
RewriteRule ^(.*)$ seo.php?p=$1 [L,QSA]
</IfModule>
Related
I have the following .htaccess file, when I type http://adidas.localhost/ in the URL the 'store' query variable does not get appended, however when I add a single character for example http://adidas.localhost/1 it will work perfectly fine, but not without any characters after the slash, I've tried everything and haven't been able to come up with a solution, thanks.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^([^\.]+)\.localhost$ [NC]
RewriteRule ^(.*)$ http://localhost/?store=%1&uri=%{REQUEST_URI} [QSA,L]
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Try with:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^([^\.]+)\.localhost$ [NC]
RewriteRule ^(.*)$ http://localhost/?store=%1&uri=%{REQUEST_URI} [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
I want to set a priority in my .htaccess.
Ok, I've got folders on my root project, schema:
-root:
-core
-includes
-pages:
- profile.php
-etc
-support
-infractions
-.htaccess
and what I want to do is:
If the URL is like https://example.com/support, show the /support/index.php.
I've tried -Indexes option but it doesn't works or doesn't meet my needs.
My .htaccess is like:
Options +FollowSymlinks
Options +Indexes
Options -MultiViews
RewriteEngine On
RewriteCond %{HTTP_HOST} ^fenixcms\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://fenixcms.com/$1 [R,L]
RewriteBase /
DirectoryIndex pages/index.php
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^alert/([^/\.]+)/?$ pages/alert.php?id=$1 [L]
RewriteRule ^player/([^/\.]+)/?$ pages/profile.php?name=$1 [L]
RewriteRule ^forums/new_topic/([^/\.]+)/?$ /forums/new_topic.php?c=$1 [L]
RewriteRule ^forums/topics/([^/\.]+)/posts/edit/([^/\.]+)/?$ /forums/edit_post.php?tid=$1&pid=$2 [L]
RewriteRule ^forums/topics/([^/\.]+)/posts/new/?$ /forums/new_post.php?tid=$1 [L]
RewriteRule ^forums/topics/([^/\.]+)/posts/reply_to_id/([^/\.]+)/?$ /forums/new_quote.php?tid=$1&pid=$2 [L]
RewriteRule ^forums/topics/([^/\.]+)/edit/?$ /forums/edit_topic.php?tid=$1 [L]
RewriteRule ^forums/topics/([^/\.]+)/?$ /forums/topic.php?id=$1 [L]
RewriteRule ^forums/topics/([^/\.]+)/posts/delete/([^/\.]+)/?$ /forums/delete_post.php?tid=$1&pid=$2 [L]
RewriteRule ^forums/categories/([^/\.]+)/?$ /forums/categories.php?s=$1 [L]
RewriteRule ^forums/posts/([^/\.]+)/?$ /forums/posts.php?pid=$1 [L]
RewriteRule ^forums/([^/\.]+)/?$ /forums/$1.php [L]
RewriteRule ^revisions/([^/\.]+)/?$ pages/revisions.php?action=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.]+)/([^/\.]+)/?$ /$1/$2.php [L]
RewriteRule ^([^\.]+)/?$ /$1/index.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ pages/$1.php [NC,L]
Below is my .htaccess file. I am trying to exclude the rewrite rules being applied to the /admin/ folder, however after spending an hour researching and trying various codes I have reached a wall.
Options -MultiViews
RewriteEngine On
RewriteBase /
# Exclude admin directory
RewriteRule ^(admin|admin)($|/) - [L]
RewriteRule ^privacy$ pages/privacy.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)/(.+)$ products.php?q=$3&rewrite=1&%{QUERY_STRING} [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)/$ search.php?q=bw:&categoryFilter=$1&genreFilter=$2%{QUERY_STRING} [L,B]
RewriteRule ^(.*)/$ pages/format.php?format=$1 [NC,L}
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
The above code brings an internal 500 error and if I remove it will redirect me to the rewrite rule for the format. I was reading that The exclusion rewrite rule needs to be placed before the rule I want to overwrite. I don't understand why it's not working and what I have missed.
Thanks.
Try and write your rule this way.
# Exclude admin directory
RewriteRule ^admin/?$ - [L]
You have a syntax error in your .htaccess.
Have your .htaccess like this:
Options -MultiViews
RewriteEngine On
RewriteBase /
# Exclude admin directory
RewriteRule ^admin($|/) - [L,NC]
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^privacy$ pages/privacy.php [NC,L]
RewriteRule ^(.+)/(.+)/(.+)$ products.php?q=$3&rewrite=1 [L,QSA]
RewriteRule ^(.*)/(.*)/$ search.php?q=bw:&categoryFilter=$1&genreFilter=$2 [L,B,QSA]
RewriteRule ^(.+)/$ pages/format.php?format=$1 [NC,L]
My .htaccess:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
#non www redirection
RewriteEngine On
RewriteCond %{HTTP_HOST} !^ruggedtrailsnepal\.com
RewriteRule (.*) http://ruggedtrailsnepal.com/$1 [R=301,L]
i am not getting / (slash) on some url , but some url's are working , how to solve this problem
link with problem
ruggedtrailsnepal.comtravel-info/visa-information.html
link without problem
ruggedtrailsnepal.com/company-info/about-us.html
Reorder your rules and use REQUEST_URI variable:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
#non www redirection
RewriteCond %{HTTP_HOST} !^ruggedtrailsnepal\.com$ [NC]
RewriteRule ^ http://ruggedtrailsnepal.com%{REQUEST_URI} [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Better test this in a new browser to avoid old caches.
I have to write a htaccess to rewrite the links as follows and also a redirection of 404
error pages to my sites root (home page)
www.example.com/index.php?page=find&name=detail&id=109&cid=8
www.example.com/index.php?page=find&name=detail&id=109
www.example.com/index.php?page=find&name=detail
www.example.com/index.php?page=find
should be rewritten to
www.example.com/find/name/detail/id/109/cid/8
www.example.com/find/name/detail/id/109
www.example.com/find/name/detail
www.example.com/find
Your htaccess rules,
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?file=$1 [L,QSA]
RewriteRule ^([a-zA-Z]+)/page/([a-zA-Z]+)/id/([0-9]+)/cid/([0-9]+)/$ index.php?page=find&name=detail&id=109&cid=8 [L]
RewriteRule ^([a-zA-Z]+)/page/([a-zA-Z]+)/id/([0-9]+)/$ index.php?page=find&name=detail&id=109 [L]
RewriteRule ^([a-zA-Z]+)/page/([a-zA-Z]+)/$ index.php?page=find&name=detail [L]
RewriteRule ^([a-zA-Z]+)/$ index.php?page=find [L]
</IfModule>
Try:
RewriteEngine On
RewriteRule ^find$ index.php?page=find [L,QSA]
RewriteRule ^(find)/([^/]+)/([^/]+)(.*)$ /$1$4?$2=$3 [L,QSA]
FallbackResource /
Try this code:
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule (.*)/([a-zA-z0-9]*)/(.*)/([a-zA-z0-9]*)/(.*)/([a-zA-z0-9]*)/(.*)/([a-zA-z0-9]*)/(.*)\.html index.php?itfpage=$1&$2=$3&$4=$5&$6=$7$8=$9 [L]
RewriteRule (.*)/([a-zA-z0-9]*)/(.*)/([a-zA-z0-9]*)/(.*)/([a-zA-z0-9]*)/(.*)\.html index.php?itfpage=$1&$2=$3&$4=$5&$6=$7 [L]
RewriteRule (.*)/([a-zA-z0-9]*)/(.*)/([a-zA-z0-9]*)/(.*)\.html index.php?itfpage=$1&$2=$3&$4=$5 [L]
RewriteRule (.*)/([a-zA-Z]*)/(.*)\.html index.php?itfpage=$1&$2=$3 [L]