my hosting error 500 if use .htaccess
this my .htaccess file
RewriteEngine On
AllowOverride All
RewriteBase /
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301]
RewriteRule ^developer.html$ developer.php [QSA,L]
RewriteRule ^multishrink.html$ multishrink.php [QSA,L]
RewriteRule ^stats.html$ public-stats.php [QSA,L]
RewriteRule ^feed.rss feed.php [QSA,L]
RewriteRule ^([^/]+)\.qrcode$ qrcode.php?id=$1 [QSA,L]
RewriteRule ^api.php$ API/simple.php [QSA,L]
RewriteRule ^API/write/(get|post)$ API/write.php?method=$1 [QSA,L]
RewriteRule ^API/read/(get|post)$ API/read.php?method=$1 [QSA,L]
RewriteRule ^([^/]+)/stats$ stats.php?id=$1 [QSA,L]
RewriteRule ^([^/]+)/unlock$ unlock.php?id=$1 [QSA,L]
RewriteRule ^privacy.html$ privacy.php [QSA,L]
RewriteRule ^disclaimer.html$ disclaimer.php [QSA,L]
RewriteRule ^contact.html$ contact.php [QSA,L]
# If path is not a directory or file then apply RewriteRule
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([0-9a-zA-Z-]{1,60})$ go.php?id=$1 [QSA,L]Options -Indexes
how to fix this
Related
I am trying to create redirections from the old urls to the new ones and I have a problem how to write appropriate htaccess rules.
old urls
domain.com/cat1/cat2/cat3/city,name
domain.com/cat1/cat2/city,name
domain.com/cat1/city,name
new urls
domain.com/cat1/cat2/cat3?city=name
domain.com/cat1/cat2?city=name
domain.com/cat1?city=name
I tried something like this but it doesn't work.
RewriteRule ^/city,(.*)$ /city=?$1 [L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^,]*),(.*)/?$ $1/$2/$3?$4=$5 [L]
RewriteRule ^([^/]*)/([^/]*)/([^,]*),(.*)/?$ $1/$2?$3=$4 [L]
RewriteRule ^([^/]*)/([^,]*),(.*)/?$ $1?$2=$3 [L]
RewriteCond %{HTTP_HOST} ^www\.domain\.pl [NC]
RewriteRule ^(.*)$ http://domain.pl/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{HTTP_HOST} !^www\.domain.pl
RewriteCond %{HTTP_HOST} ^(.+).domain.pl
RewriteRule ^([^/]*)$ http://domain.pl/account/firma/%1 [P,L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
EDIT: As per OP's edit adding following now.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domain\.pl [NC]
RewriteRule ^(.*)$ http://domain.pl/$1 [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.domain.pl
RewriteCond %{HTTP_HOST} ^(.+).domain.pl
RewriteRule ^([^/]*)$ http://domain.pl/account/firma/%1 [P,L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^,]*),(.*)/?$ $1/$2/$3?$4=$5 [L]
RewriteRule ^([^/]*)/([^/]*)/([^,]*),(.*)/?$ $1/$2?$3=$4 [L]
RewriteRule ^([^/]*)/([^,]*),(.*)/?$ $1?$2=$3 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
With your shown samples, could you please try following. Please make sure you clear your browser cache before testing your URLs.
RewriteEngine ON
##To deal with domain.com/cat1/cat2/cat3/city,name URLs
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^,]*),(.*)/?$ $1/$2/$3?$4=$5 [L]
##To deal with domain.com/cat1/cat2/city,name URLs
RewriteRule ^([^/]*)/([^/]*)/([^,]*),(.*)/?$ $1/$2?$3=$4 [L]
##To deal with domain.com/cat1/city,name URLs
RewriteRule ^([^/]*)/([^,]*),(.*)/?$ $1?$2=$3 [L]
You can try this full .htaccess code. Make sure you don't have anything extra apart from this code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?!www\.)(.+)\.(domain\.pl)$ [NC]
RewriteRule ^ http://%1/account/firma%{REQUEST_URI} [P,L]
RewriteCond %{HTTP_HOST} ^www\.(domain\.pl)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/([^,]+),([^/]+)/?$ $1?$2=$3 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Also make sure to clear your browser cache completely before testing this change.
Im trying to change my urls from mywebsite.co/keyword to mywebsite.co/web/keyword i found a few ways to do this but it always causes problems with my other rewrites here is what i have so far only problem with it is it wont redirect mywebsite.co/keyword to mywebsite.co/web/keyword
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteBase /
RewriteRule ^screenshot/ - [L]
# If requested resource exists as a file or directory, skip next two rules
RewriteCond %{DOCUMENT_ROOT}/$1 -f [OR]
RewriteCond %{DOCUMENT_ROOT}/$1 -d
RewriteRule (.*) - [S=2]
# when there is no space make an external redirection
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^info/([0-9a-zA-Z]+) /search/info/info.php?keyword=$1 [QSA,L]
RewriteRule ^web/([0-9a-zA-Z]+) /search/web/index.php?search=$1 [QSA,L]
RewriteRule ^videos/([0-9a-zA-Z]+) /search/video/video.php?keyword=$1 [QSA,L]
RewriteRule ^images/([0-9a-zA-Z]+) /search/images/image.php?keyword=$1 [QSA,L]
RewriteRule ^news/([0-9a-zA-Z]+) /search/news/news.php?keyword=$1 [QSA,L]
RewriteRule ^products/([0-9a-zA-Z]+) /search/products/product.php?keyword=$1 [QSA,L]
RewriteRule ^maps/([0-9a-zA-Z]+) /search/maps/maps.php?keyword=$1 [QSA,L]
RewriteRule ^space/([0-9a-zA-Z]+) /search/space/space.php?keyword=$1 [QSA,L]
RewriteRule ^web/ /search/web/index.php [QSA,L]
RewriteRule ^info/ /search/info/info.php [QSA,L]
RewriteRule ^videos/ /search/video/video.php [QSA,L]
RewriteRule ^images/ /search/images/image.php [QSA,L]
RewriteRule ^news/ /search/news/news.php [QSA,L]
RewriteRule ^products/ /search/products/product.php [QSA,L]
RewriteRule ^maps/ /search/maps/maps.php [QSA,L]
RewriteRule ^space/ /search/space/space.php [QSA,L]
Have it this way:
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteBase /
RewriteRule ^screenshot/ - [L]
# If requested resource exists as a file or directory, skip next two rules
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^info/([0-9a-zA-Z]+)/?$ /search/info/info.php?keyword=$1 [QSA,L]
RewriteRule ^web/([0-9a-zA-Z]+)/?$ /search/web/index.php?search=$1 [QSA,L]
RewriteRule ^videos/([0-9a-zA-Z]+)/?$ /search/video/video.php?keyword=$1 [QSA,L]
RewriteRule ^images/([0-9a-zA-Z]+)/?$ /search/images/image.php?keyword=$1 [QSA,L]
RewriteRule ^news/([0-9a-zA-Z]+)/?$ /search/news/news.php?keyword=$1 [QSA,L]
RewriteRule ^products/([0-9a-zA-Z]+)/?$ /search/products/product.php?keyword=$1 [QSA,L]
RewriteRule ^maps/([0-9a-zA-Z]+)/?$ /search/maps/maps.php?keyword=$1 [QSA,L]
RewriteRule ^space/([0-9a-zA-Z]+) /search/space/space.php?keyword=$1 [QSA,L]
RewriteRule ^web/?$ /search/web/index.php [QSA,L]
RewriteRule ^info/?$ /search/info/info.php [QSA,L]
RewriteRule ^videos/?$ /search/video/video.php [QSA,L]
RewriteRule ^images/?$ /search/images/image.php [QSA,L]
RewriteRule ^news/?$ /search/news/news.php [QSA,L]
RewriteRule ^products/?$ /search/products/product.php [QSA,L]
RewriteRule ^maps/?$ /search/maps/maps.php [QSA,L]
RewriteRule ^space/?$ /search/space/space.php [QSA,L]
Here's my code
RewriteRule ^error$ error.php [QSA,L]
RewriteRule ^siteuri_partenere$ siteuri_partenere.php [QSA,L]
RewriteRule ^politica_de_confidentialitate$ politica_de_confidentialitate.php [QSA,L]
RewriteRule ^blog - [L,NC]
RewriteRule ^([^/.]+)/?$ game.php?weblink=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /error [L,R=302]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
So, if i change this line
RewriteRule . /error [L,R=302]
to
RewriteRule . /page_not_found [L,R=302]
and then i test www.domain.com/1q2w3e, is still redirect to /error and not to /page_not_found so i'm very confusing where is the problem?
Most likely you have some ErrorDocument 404 directive that is overriding your rewrite rules. Place this code in your root .htaccess:
Options +FollowSymLinks -MultiViews
ErrorDocument 404 default
RewriteEngine On
RewriteRule ^blog - [L,NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^error$ error.php [L]
RewriteRule ^siteuri_partenere$ siteuri_partenere.php [L]
RewriteRule ^politica_de_confidentialitate$ politica_de_confidentialitate.php [L]
RewriteRule ^([^/.]+?)/?$ game.php?weblink=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /page_not_found [L,R=302]
I want to redirect site from www to non-www.
The main issue is that .htaccess file of CMS is very complicated.
Otherwise this instruction in the start of the .htaccess should have worked
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.ecotrans-spb.ru$ [NC]
RewriteRule ^(.*)$ http://ecotrans-spb.ru/$1 [R=301,L]
What flags should I set here instead of these to allow .htaccess process the URL further?
Generic CMS .htaccess
AddDefaultCharset UTF-8
ErrorDocument 404 /404
ErrorDocument 401 /password.php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.ecotrans-spb.ru$ [NC]
RewriteRule ^(.*)$ http://ecotrans-spb.ru/$1 [R=301]
# Админка теперь по адресу /simpla
RewriteRule ^admin/?$ simpla [L]
# Каталог товаров
RewriteRule ^catalog/([^/]+)/?$ index.php?module=ProductsView&category=$1 [L,QSA]
RewriteRule ^catalog/([^/]+)/([^/]+)/?$ index.php?module=ProductsView&category=$1&brand=$2 [L,QSA]
RewriteRule ^products/([^/]+)/?$ index.php?module=ProductView&product_url=$1 [L,QSA]
RewriteRule ^products/?$ index.php?module=ProductsView [L,QSA]
RewriteRule ^brands/([^/]+)/?$ index.php?module=ProductsView&brand=$1 [L,QSA]
RewriteRule ^brands/([^/]+)/page_([^/]+)/?$ index.php?module=ProductsView&brand=$1&page=$2 [L,QSA]
# Поиск товаров
RewriteRule ^search/([^/]+)/?$ index.php?module=ProductsView&keyword=$1 [L,QSA]
RewriteRule ^search/?$ index.php?module=ProductsView [L,QSA]
# Блог
RewriteRule ^blog/([^/]+)/?$ index.php?module=BlogView&url=$1 [L,QSA]
RewriteRule ^blog/?$ index.php?module=BlogView [L,QSA]
# Корзина и заказы
RewriteRule ^cart/?$ index.php?module=CartView [L,QSA]
RewriteRule ^cart/([^/]+)/?$ index.php?module=CartView&add_variant=$1 [L,QSA]
RewriteRule ^cart/remove/([^/]+)/?$ index.php?module=CartView&delete_variant=$1 [L,QSA]
RewriteRule ^order/([^/]+)/?$ index.php?module=OrderView&url=$1 [L,QSA]
RewriteRule ^order/?$ index.php?module=OrderView [L,QSA]
# Для пользователей
RewriteRule ^user/login/?$ index.php?module=LoginView [L,QSA]
RewriteRule ^user/register/?$ index.php?module=RegisterView [L,QSA]
RewriteRule ^user/logout/?$ index.php?module=LoginView&action=logout [L,QSA]
RewriteRule ^user/password_remind/?$ index.php?module=LoginView&action=password_remind [L,QSA]
RewriteRule ^user/password_remind/([0-9a-z]+)/?$ index.php?module=LoginView&action=password_remind&code=$1 [L,QSA]
RewriteRule ^user/?$ index.php?module=UserView [L,QSA]
# Google sitemap
RewriteRule ^sitemap.xml?$ sitemap.php [L,QSA]
# XML
RewriteRule ^yandex.xml?$ yandex.php [L,QSA]
# feedback
RewriteRule ^contact/?$ index.php?module=FeedbackView [L,QSA]
#downloads
RewriteRule ^order/([^/]+)/([^/]+)/?$ index.php?module=OrderView&url=$1&file=$2 [L,QSA]
# Статические страницы
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/?$ index.php?module=PageView&page_url=$1 [L,QSA]
RewriteRule ^/?$ index.php?module=MainView&page_url= [L,QSA]
# Ресайз картинок на лету
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^files/products/(.+) resize/resize.php?file=$1&token=%{QUERY_STRING}
#RewriteCond %{THE_REQUEST} ^GET\ (.*)files/products/(.*)\?([A-z0-9]*)
#RewriteRule ^files/products/(.+) resize/resize.php?file=%2&token=%3 [L,NE]
Removing the L from the last line will allow it to continue.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.ecotrans-spb.ru$ [NC]
RewriteRule ^(.*)$ http://ecotrans-spb.ru/$1 [R=301]
[L] is a flag that, if this rule matches, then no other rule matching will be performed.
What is wrong with this line
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([^/]*)$ /index.php?query=$1 [L]
I'm try rewrite links from
http://mysite.com/index.php?query=2012
to
http://mysite.com/2012
But i have 500 Internal Server Error
Also here is the content from my htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^software$ index.php?type=app
RewriteRule ^movies$ index.php?type=movie
RewriteRule ^games$ index.php?type=game
RewriteRule ^music$ index.php?type=music
RewriteRule ^other$ index.php?type=other
RewriteRule ^tv$ index.php?type=tv-show
RewriteRule ^ebooks$ index.php?type=ebooks
RewriteRule ^(.*)-(\d+)\.html$ download.php?id=$2 [L,NC]
RewriteRule ^site/([^/]*)$ /index.php?site=$1 [L]
RewriteRule ^([^/]*)$ /index.php?query=$1 [L]
Replace this rule:
RewriteRule ^([^/]*)$ /index.php?query=$1 [L]
with this:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([^/]*)/?$ index.php?query=$1 [L,QSA]