I have such URL at my Magento website as http://magento.store/about and http://magento.store/index.php/about. I don't need these two pages, I need them to be properly rewrited in .htaccess file. I've tried everything which I could find at StackOverflow but nothing helps. I configured URL-rewrites in configuration using adpanel, used different solutions but the most, I got is to do these redirects but my adpanel doesn't writes any changes to the website's database (I used this solution:
RedirectMatch 301 ^/index.php/((?!admin).*) http://www.magento.store/$1
In this case it is impossible to change anything in adpanel. The usual solutions such as
RewriteEngine on
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
do not also work. They are ignored as far as I understand.
How can I solve this issue?
Here is my .htaccess file (the part about the mod_rewrite):
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP_HOST} ^magento\.store$ [NC]
RewriteRule ^(.*)$ http://www.magento.store/$1 [L,R=301]
# redirect pagination
RewriteCond %{QUERY_STRING} ^p=1$
RewriteRule ^(.+)$ http://www.magento.store/$1? [R=301,L]
RewriteRule ^pagename$ http://www.magento.store/page-name [L,R=301]
#RewriteCond %{REQUEST_URI} !/admin/
#RewriteRule ^index\.php/(.+)$ /$1 [R,L]
#RewriteRule ^index\.php/?$ / [R,L]
#RedirectMatch 301 ^/index.php/(.*)$ /$1
#RedirectMatch 301 ^/index.php/((?!admin).*) http://magento.store/$1
RewriteRule ^api/rest api.php?type=rest [QSA,L]
############################################
## workaround for HTTP authorization
## in CGI environment
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
############################################
## TRACE and TRACK HTTP methods disabled to prevent XSS attacks
RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
RewriteRule .* - [L,R=405]
############################################
## always send 404 on missing files in these folders
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
############################################
## never rewrite for existing files, directories and links
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
############################################
## rewrite everything else to index.php
RewriteRule .* index.php [L]
</IfModule>
Is it possible that I have some conflicts inf my file?
You can capture the part after index.php and redirect the client with
RewriteEngine on
RewriteRule ^index\.php/(.+)$ /$1 [R,L]
RewriteRule ^index\.php/?$ / [R,L]
This redirects all requests starting with index.php/ to the URL without index.php. Additionally index.php and index.php/ are redirected to the home page.
Use below .htaccess rule:
## index.php on default domain
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteCond %{REQUEST_URI} !^/downloader.*$
RewriteRule ^(.*)index.php$ http://www.idesignmydrapes.com [R=301,L]
RewriteCond %{HTTP_HOST} ^idesignmydrapes\.com$ [NC]
Thank you, everybody, for your help. Finally, I made the solution and it is the following:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !/adpanel/
RewriteRule ^index\.php/(.*)$ http://magento.store/$1 [L,R=301]
Related
Recently, we switched from www.example.deto www.example.com/de. Unfortunately some minor and bigger issue occurred with the .htaccess.
Issue
Redirect chain
www.example.de/path redirects to www.example.com/de/path an then to www.example.com/de/path/
How do I remove the unecessary redirect?
Every blog article gets redirected to http and then to https.
https://www.example.de/blog/article redirects to http://example.com/blog/article/ then to https://example.com/blog/article/ and finally to https://example.com/de/blog/article/
The redirect to http only occurs for the blog. The rest off the website doesnt redirect to http.
It seems to me that the htaccess is ignored by requests to the blog. I don`t know what I did wrong!
htaccess www.example.de:
SetEnv PHPRC /home/customer/www/example.de/public_html/php.ini
RewriteEngine on
RewriteRule ^(.*)$ https://www.example.com/de/$1 [R=301,L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
htaccess www.example.com/de:
SetEnv PHPRC /home/customer/www/example.com/public_html/php.ini
# BEGIN rlrssslReallySimpleSSL rsssl_version[5.1.0]
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Possible Solution
Can I add this to solve the Issue with the trailing slash?
RewriteCond %{REQUEST_URI} /(.+)/$
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ https://www.example.com/%1 [R=301,L]
htaccess in root folder
#<IfModule mod_rewrite.c>
#RewriteEngine On
#Uncomment these two lines If you want to redirect http to https
#RewriteCond %{HTTPS} off
#RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php [L]
#</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^https://3pmix.com/ [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
htaccess in sub folder
RewriteRule ^classes/.*$ - [F,L]
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} config.php|db.php|functions.php [NC]
RewriteRule .* - [F,L]
directory structure through images
With your shown samples, please try following Rules file. Also make sure to clear your browser cache before testing your URLs.
Have your root htaccess Rule file like as follows:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^3pmix\.com [NC]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
</IfModule>
And have your sub directory htaccess Rules file as follows:
RewriteOptions InheritBefore
RewriteEngine ON
RewriteRule ^classes - [NC,F,L]
RewriteRule (?:config\.php|db\.php|functions\.php) - [NC,F,L]
I have also fixed flags and regex in your htaccess files.
Rewrite base was missing that is why was not finding the root url of the website
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]
</IfModule>
In my Laravel app I added to the /public/.htaccess/ file a RewriteRule like this:
RewriteRule ^resources/pdf/?$ /about
however, if I call www.mydomain.com/resources/pdf/ the I only get this error:
although my server uses APACHE and the other htaccess entries do work. Also www.mydomain.com/about does work.
Why is this not working? Here is the full htaccess file:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteRule ^resources/pdf/?$ /about [L]
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Try with:
RewriteRule ^resources/pdf/?$ about [NC]
Which works with www.mydomain.com/resources/pdf/ and www.mydomain.com/resources/pdf
I was missing the [L]:
RewriteRule ^resources/pdf/?$ /about [L]
Also I had to clear cache and view the page in incognito mode to witness the effect.
I am working on a hacked site that has thousands of 404 errors now that I have fixed it. I want to redirect everything in the folders that were from the hack back to the home page. For example, this is one of the hacked urls:
http://www.truckeeriverrock.com/scategory/aqrqxjfo-x10001-zlggclj/whlhgxtx-y298119-bucavsa/
I am trying to do this via the .htaccess file. It is a wordpress website so I already have some standard rewrite rules. Basically I tried the following but it breaks the site with an internal server error:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^scategory/(.*) http://www.truckeeriverrock.com/$1 [R=301,L]
RewriteRule ^whosonline/(.*) http://www.truckeeriverrock.com/$1 [R=301,L]
RewriteRule ^admintools/(.*) http://www.truckeeriverrock.com/$1 [R=301,L]]
</IfModule>
# END WordPress
If I take out the following rewrite rules it works but of course it doesn't redirect:
RewriteRule ^scategory/(.*) http://www.truckeeriverrock.com/$1 [R=301,L]
RewriteRule ^whosonline/(.*) http://www.truckeeriverrock.com/$1 [R=301,L]
RewriteRule ^admintools/(.*) http://www.truckeeriverrock.com/$1 [R=301,L]]
Could someone help me with my rules?
Keep your 301 rules before default WP rules.
RewriteEngine On
RewriteBase /
RewriteRule ^scategory/(.*) http://www.truckeeriverrock.com/$1 [R=301,L]
RewriteRule ^whosonline/(.*) http://www.truckeeriverrock.com/$1 [R=301,L]
RewriteRule ^admintools/(.*) http://www.truckeeriverrock.com/$1 [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
This is because WP rule changes REQUEST_URI to /index.php hence your rules fail to match given patterns.
I feel this should be an easy fix but I'm struggling to get it done right.
I have the URL:
http://www.testing.com/toursgbr/my-post
http://www.testing.com/toursgbr/my-post-2
I need to rewrite the URL to:
http://www.testing.com/tours/gbr/my-post
http://www.testing.com/tours/gbr/my-post-2
I got as far as the following:
RewriteRule ^toursgbr/(.*) /tours\/gbr/$1 [L]
This is what's currently in the htaccess file:
RewriteEngine on
ErrorDocument 404 http://www.ausweb.com.au/web-hosting
AddHandler server-parsed html
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteCond %{HTTP_HOST} ^seabreezepark\.com\.au$ [OR]
RewriteCond %{HTTP_HOST} ^www\.seabreezepark\.com\.au$
RewriteRule ^/?$ "http\:\/\/theseabreezepark\.com\.au\/" [R=301,L]
RewriteRule ^toursgbr/(.+)$ /tours/gbr/$1 [NC,L]
and got nowhere pretty fast. I just want to look for the word "toursgbr" and change it to "tours/gbr" in summary.
Put the Following code at root .htaccess file :
RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} !\s/+tours/gbr/ [NC]
# the above line will exclude any request having tours/gbr/ from the follwoing rule.
RewriteRule ^toursgbr/(.*)$ tours/gbr/$1 [R=302,L,NE]
# the above line will change any requested url having toursgbr/ to be tours/gbr/ temporary
# and you can change it to permanent by changing [R=302,L,NE] to [R=301,L,NE]
# but check the code as it is first then change it
RewriteRule ^tours/gbr/(.*)$ toursgbr/$1 [L,NC]
# the above line will internally map any request having tours/gbr/ to its original path
Try :
RewriteRule ^toursgbr/(.+)$ /tours/gbr/$1 [NC,L]
Do not use the full url in rewrite target if you want to internally redirect /toursgbr/foo to /tours/gbr/foo without changing the url in browser.
Your corrected htaccess :
ErrorDocument 404 http://www.ausweb.com.au/web-hosting
AddHandler server-parsed html
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?seabreezepark\.com\.au$
RewriteRule ^/?$ http://theseabreezepark.com.au/ [L,R=301]
RewriteRule ^toursgbr/(.+)$ /tours/gbr/$1 [NC,L]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]