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]
Related
I am trying to use pretty urls so https://example.com/event/1/dog-singing will load https://example.com/events?action=show&id=1
I added the following code to my .htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^event/([^/]*)/?(.*)$ events?action=show&id=$1 [L,NC]
I get a 404 page.
I tried using
RewriteRule ^event/([^/]*)/?(.*)$ index\.php/events?action=show&id=$1 [L,NC]
Same 404 page.
The below rewrite works. But I don't want to load the script from the subdirectory.
RewriteRule ^event/([^/]*)/?(.*)$ wp-content/plugins/testplugin/testplugin\.php?action=show&id=$1 [L,NC]
The one below also works. But it changes the pretty url in the address bar.
RewriteRule ^event/([^/]*)/?(.*)$ https://example.com/events?action=show&id=$1 [L,NC]
EDIT
Here is the full .htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^event/([^/]*)/[^/]*/?$ index.php?action=show&id=$1 [QSA,L,NC]
RewriteRule ^register/([^/]*)/?(.*)$ wp-content/plugins/testplugin/testplugin\.php?action=register&event=$1&name=$2 [L]
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<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>
# END WordPress
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]
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.
Having gone through some suggestions about rewriting static url to php url i have hit snag trying to redirect http://www.example.com/clothing to http://www.example.com/index.php?main_page=index&cPath=999
using this rule
RewriteRule ^clothing/index.html index.php?main_page=index&cPath=999 [L]
I keep getting
rewriterule: bad flag delimiter
even after changing/adding / and \ to the rule.
This is my .htaccess file
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# From Ultimate SEO URLs
RewriteRule ^(.*)-p-(.*).html$ index\.php?main_page=product_info&products_id=&% {QUERY_STRING} [L]
RewriteRule ^(.*)-c-(.*).html$ index\.php?main_page=index&cPath=&%{QUERY_STRING} [L]
RewriteRule ^(.*)-m-([0-9]+).html$ index\.php?main_page=index&manufacturers_id=&%{QUERY_STRING} [L]
RewriteRule ^(.*)-pi-([0-9]+).html$ index\.php?main_page=popup_image&pID=&%{QUERY_STRING} [L]
RewriteRule ^(.*)-pr-([0-9]+).html$ index\.php?main_page=product_reviews& products_id=&%{QUERY_STRING} [L]
RewriteRule ^(.*)-pri-([0-9]+).html$ index\.php?main_page=product_reviews_info&products_id=&%{QUERY_STRING} [L]
RewriteRule ^(.*)-ezp-([0-9]+).html$ index\.php?main_page=page&id=&%{QUERY_STRING} [L]
# All other pages
# Don't rewrite real files or directories
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*).html$ index\.php?main_page=&%{QUERY_STRING} [L]
I have a problem with making friendly URL. I need to convert url from http://blabla.eu/stats_details?date=01-2012 to http://blabla.eu/stats_details/01-2012. Other Rewrite rules are working properly beside the last one. What is the problem?
Here is code of .htaccess:
AddDefaultCharset utf-8
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^admin/users/$ /admin/users/view.php [L]
RewriteRule ^admin/loans/$ /admin/loans/view.php [L]
RewriteRule ^stats_details/(.*)$ stats_details.php?date=$1 [L,QSA]
</IfModule>
I think this must to work, try to paste
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]