hello this is my htaccess code
Options All -Indexes
ErrorDocument 404 /404.php
FileETag MTime Size
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /lang/
RewriteRule ^sitemap\.xml$ index.php [L]
RewriteRule ^(.*)(\.html|\.htm)$ index.php [L]
RewriteRule ^(.*)(\.rss|\.atom|\.txt)$ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ index.php [L]
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/gif "access plus 1 months"
ExpiresByType image/jpeg "access plus 1 months"
ExpiresByType image/png "access plus 1 months"
ExpiresByType text/css "access plus 1 months"
ExpiresByType application/x-javascript "access plus 1 months"
</IfModule>
i have this contact form
http://www.example.com/lang/contact-se
when user use the form and contact
it redirect to
http://www.example.com/lang/contact-se.html
and give me error page not found
how can i exclude this link only from rewrite and redirect to .html
Change your form to submit to /lang/contact-se instead of /lang/contact-se.html.
Not sure what this has to do with your rules, both contact-se and contact-se.html gets pointed to index.php.
Related
I have managed to remove the .php extension using the below htaccess code but the issue i face now is index.php shows like www.site.com/index
could someone help me out to rename it to www.site.com/home instead of /index?
Here is my complete htaccess file
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ pages.php?$1 [L,QSA]
RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [NC,L]
RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [NC,L]
<IfModule mod_deflate.c>
<FilesMatch "\.(css|x?html?|php)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
<IfModule mod_expires.c>
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/html "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
</IfModule>
<IfModule mod_rewrite.c>
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F,L]
</IfModule>
Really appreciate your kind help.
Could you please use following Rules set in your .htaccess file once. Please make sure to clear your browser cache before testing your URLs.
RewriteEngine On
RewriteBase /
##new redirection rules here for index.php to home.
RewriteRule ^index\.php/?$ /home? [R=301,NC,L]
RewriteRule ^home/?$ site/index.php [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ pages.php?$1 [L,QSA]
RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [NC,L]
RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [NC,L]
<IfModule mod_deflate.c>
<FilesMatch "\.(css|x?html?|php)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
<IfModule mod_expires.c>
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/html "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
</IfModule>
<IfModule mod_rewrite.c>
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [NC,OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) [NC]
RewriteRule .* index.php [F,L]
</IfModule>
pls, help me to resolve this issues, we are facing this problem from last couple of days.
I have a problem with my .htaccess
I have set my $base_url = http://localhost/example.com/ Like this
I have a URL that looks like:
http://localhost/example.com/test.php?id=10
I want to convert this url like this :
http://localhost/example.com/10
Here is my .Htaccess code
RewriteEngine On
<ifModule mod_headers.c>
Header set Connection keep-alive
</ifModule>
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##
#AddOutputFilterByType DEFLATE text/plain
#AddOutputFilterByType DEFLATE text/html
#AddOutputFilterByType DEFLATE text/xml
#AddOutputFilterByType DEFLATE text/css
#AddOutputFilterByType DEFLATE application/xml
#AddOutputFilterByType DEFLATE application/xhtml+xml
#AddOutputFilterByType DEFLATE application/rss+xml
#AddOutputFilterByType DEFLATE application/javascript
#AddOutputFilterByType DEFLATE application/x-javascript
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^\.]+)$ $1.html [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)/?$ $0.php [NC,L]
RewriteRule ^user/profile/([A-Za-z0-9-\s&/()+']+) user-profile-edit.php?name=$1 [NC,B,L]
RewriteRule ^user/profile user-profile.php [NC,B,L]
RewriteRule ^user/dashboard user-dashboard.php [NC,B,L]
RewriteRule ^user/address user-addresses.php [NC,B,L]
RewriteRule ^user/add-address user-address-add.php [NC,B,L]
RewriteRule ^user/booking user-booking.php [NC,B,L]
# Condition For Test Page
RewriteCond %{QUERY_STRING} (^|&)id=\$1($|&)
RewriteRule ^tests\.php$ /$1?&%[R=301,L]
So How to fix this problem?
Inside example.com/.htaccess you may try these rules:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+([^/]+)/test\.php\?id=([\w-]+)\sHTTP [NC]
RewriteRule ^ /%1/%2? [R=302,L,NE]
RewriteRule ^user/profile/([-\w\s&/()+']+)/?$ user-profile-edit.php?name=$1 [NC,QSA,L]
RewriteRule ^user/profile/?$ user-profile.php [NC,L]
RewriteRule ^user/dashboard/?$ user-dashboard.php [NC,L]
RewriteRule ^user/address/?$ user-addresses.php [NC,L]
RewriteRule ^user/add-address user-address-add.php [NC,L]
RewriteRule ^user/booking/?$ user-booking.php [NC,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+?)/?$ $1.html [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
RewriteRule ^([\w-]+)/?$ test.php?id=$1 [QSA,L]
I want/need to rewrite all my product urls
for example a product url in three languages.
mainurl.com/en/outdoor/wood-table
mainurl.com/de/außenbereich/holz-tisch
mainurl.com/it/esterno/tavolo-legno
What url i want/need is:
mainurl.com/products/en/outdoor/wood-table
mainurl.com/products/de/außenbereich/holz-tisch
mainurl.com/products/it/esterno/tavolo-legno
Running the Shop Local with xampp in the Root-Folder htdocs.
How can i rewrite this url via .htaccess and making this fake subfolder after the mainurl?
This is the original .htaccess file that is included in the Shopsystem xt:commerce:
# RewriteEngine on
# RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
DirectoryIndex index.php
<IfModule mod_rewrite.c>
SetEnv HTTP_MOD_REWRITE On
Options -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/media/
RewriteCond %{REQUEST_URI} !^/xtAdmin/
RewriteCond %{REQUEST_URI} !^/skin/
RewriteCond %{REQUEST_URI} !^/js/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType image/x-icon "access plus 2692000 seconds"
ExpiresByType image/jpeg "access plus 2692000 seconds"
ExpiresByType image/png "access plus 2692000 seconds"
ExpiresByType image/gif "access plus 2692000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 2692000 seconds"
ExpiresByType text/css "access plus 2692000 seconds"
ExpiresByType text/javascript "access plus 2692000 seconds"
ExpiresByType application/x-javascript "access plus 2692000 seconds"
</IfModule>
<IfModule mod_headers.c>
<FilesMatch "\\.(ico|jpe?g|png|gif|swf|css|js)$">
Header set Cache-Control "max-age=2692000, public"
</FilesMatch>
Header unset ETag
Header unset Last-Modified
</IfModule>
Insert this rule just below RewriteEngine on:
RewriteRule ^product/(.*) $1 [L,NC]
I was trying to edit my htaccess file to redirect from http to https.
This one works for all pages except the homepage for every language:
http://cinqueterre.a-turist.com/deu
redirects to
https://cinqueterre.a-turist.com/https://cinqueterre.a-turist.com/deu
It's a little complicated script
Here is it:
Update: I improved a little the script, now it's not such complicated, and doesn't work if I add https redirect
DirectoryIndex 1.php index.html$ index.php
ErrorDocument 404 /404.php
RewriteEngine on
Options -Multiviews
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{HTTPS_HOST} ^www\.cinqueterre\.a\-turist\.com$ [NC]
RewriteRule (.*) https://cinqueterre.a-turist.com/$1 [R=301,L]
RewriteCond %{HTTPS_HOST} ^cinqueterre.a-turist\.com$ [OR]
RewriteCond %{HTTPS_HOST} ^www\.cinqueterre.a-turist\.com$
RewriteRule ^(rus|ita|fra|deu|ukr|pol|esp)\/index\.php$ https\:\/\/cinqueterre.a-turist\.com\/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]
#if its not a directory
RewriteCond %{REQUEST_FILENAME} !-d
#and it has a trailing slash then redirect to URL without slash
RewriteRule ^(.+)/$ /$1 [L,R=301]
Options All -Indexes
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>
Try getting rid of all of your redirects, they're in the wrong place.
You need to add redirects before this rule:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]
And you want something like this:
RewriteCond %{THE_REQUEST} \ /+.*index\.php
RewriteRule ^(rus/|ita/|fra/|deu/|ukr/|pol/|)index\.php$ https://cinqueterre.a-turist.com/$1 [R=301,L]
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^(www\.)?cinqueterre.a-turist\.com$ [NC]
RewriteRule ^(.*)$ https://cinqueterre.a-turist.com/$1 [R=301,L]
I'm attempting to redirect an internal link via .htaccess file and it's not working. Below is my .htaccess file '# Redirects'.
How might I better structure the code to allow working redirection links?
# Use PHP 5.3
AddType application/x-httpd-php53 .php
# Redirect www to non-www
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# Redirects
Redirect 301 /oldpage http://domain/newpage
# Start Hotlink Protection
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]
# EXPIRES CACHING
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/js "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
Your redirect statement is part of mod_alias, but all the rest of the rewrite rules you have belong to mod_rewrite. Those two modules processes the request at different points of the processing pipeline, so if you use them concurrently, sometimes they'll not play nicely with each other. You should just use mod_rewrite in this case as well as putting the redirect rule BEFORE your wordpress routing rules. This is because wordpress will route what you actually want to redirect.
So:
# Use PHP 5.3
AddType application/x-httpd-php53 .php
# Redirect www to non-www
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
#### INSERT THE REDIRECTS HERE
# Redirects
RewriteRule ^oldpage(.*)$ http://domain/newpage$1 [L,R=301]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
### Remove the redirect from here
# Start Hotlink Protection
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]
And then the rest of your htaccess file