please help with converting the htaccess file into caddyfile. We tried it with self-help but unsuccessfully. Can you look at it and help? Thank you
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^assets/(.*)$ public/assets/$1 [L]
RewriteRule ^wallpapers/(.*)$ public/wallpapers/$1 [L]
RewriteRule ^verify-existence$ public/verify.php [QSA,L]
RewriteRule ^proxy.php$ public/proxy.php [QSA,L]
RewriteRule ^api/v([0-9]*)/(.*)/?$ public/api.php?path_info=$2&api_version=$1 [QSA,L]
RewriteRule ^$ public/router.php [QSA,L]
RewriteRule ^(.*) public/router.php?path_info=$1 [QSA,L]
</IfModule>
Related
RewriteEngine On
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.elancemart\.com [NC]
RewriteRule (.*) https://elancemart.com/$1 [L,R=301]
</IfModule>
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule ^services/([a-zA-Z0-9-]+) service_details.php?slug=$1 [NC,L]
RewriteRule ^category/([a-zA-Z-]+) category.php?catSlug=$1 [NC,L]
RewriteRule ^blog/([0-9]+)/([a-zA-Z0-9-]+) blog/article.php?id=$1&&slug=$2 [NC,L]
RewriteRule ^verify/([a-zA-Z0-9-]+) verify.php?verify=$1 [NC,L]
RewriteRule ^services services.php
RewriteRule ^services/page/([\d])$ /services.php?page=$1 [NC,L,QSA]
RewriteRule ^funds add-funds.php [NC,L]
RewriteRule ^sitemap\.xml/?$ sitemap.php
RewriteRule ^article-sitemap\.xml/?$ article-sitemap.php
ErrorDocument 404 /index.php
I am getting 404 error when hitting services/page/([\d+])$ /services.php?page=$1
The file exists, though When I change the rewrite rule to service/page/([\d+])$ it is working fine, I need services in the URL, not service.
With your shown samples, please try following htaccess rules in your htaccess file. I have put 3 of services rules one after another to make it easy looking.
Also make sure your htaccess file is present along side with servcies.php file.
Please make sure to clear your browser cache before testing your URLs.
RewriteEngine On
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.elancemart\.com [NC]
RewriteRule ^(.*)/?$ https://elancemart.com/$1 [L,R=301]
</IfModule>
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)/?$ $1.php [L]
RewriteRule ^services/(\w+)/?$ service_details.php?slug=$1 [NC,L]
RewriteRule ^services/?$ services.php [NC,L]
RewriteRule ^services/page/(\d+)/?$ services.php?page=$1 [NC,L,QSA]
RewriteRule ^category/([a-zA-Z-]+)/?$ category.php?catSlug=$1 [NC,L]
RewriteRule ^blog/([0-9]+)/(\w+)/?$ blog/article.php?id=$1&&slug=$2 [NC,L]
RewriteRule ^verify/(\w+)/?$ verify.php?verify=$1 [NC,L]
RewriteRule ^funds/?$ add-funds.php [NC,L]
RewriteRule ^sitemap.xml/?$ sitemap.php [NC,L]
RewriteRule ^article-sitemap.xml/?$ article-sitemap.php [NC,L]
ErrorDocument 404 /index.php
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.
I'm in this situation
http://example.com/sub-domain/
and I wish to have this
http://example.com/sub/domain/
without loosing in SEO, what's the right RewriteRule?
At the moment this is my .htaccess file in the subdomain DOCUMENT_ROOT
Options -Indexes +FollowSymLinks
RewriteEngine On
RewriteBase /sub-domain/
# exclude any paths that are not codeigniter-app related
RewriteCond %{REQUEST_URI} !^/server-status
RewriteCond %{REQUEST_URI} !^/server-info
RewriteCond %{REQUEST_URI} !^/docs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
# the following is for rewritting under FastCGI
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
EDIT
In my root domain I have installed Wordpress and this is the .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [QSA,L]
</IfModule>
Leave /sub-domain/.htaccess as is. And have this rule in root .htaccess (a level above /sub-domain/):
RewriteEngine On
RewriteCond %{THE_REQUEST} /sub-domain(\S*)\s [NC]
RewriteRule ^ /sub/domain%1? [R=301,L,NE]
RewriteRule ^sub/domain(/.*)?$ sub-domain$1 [L,NC]
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]
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]