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]
Related
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]
Here is the what I'm trying to do. I've got these urls, Old form and New form
site.com/video.php -> site.com/video
site.com/index.php?cat_id=1 -> site.com/some-cat-name
Here is my htaccess file which is working only if one of the last two is commented.
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^\.htaccess$ - [F]
RewriteCond $1 !^(index\.php|img|js|css|admin|robots\.txt)
RewriteRule ^video$ /videos.php/$1 [L]
#RewriteRule ^(.*)$ /index.php/$1 [L]
if those two are active the server returns error 500
RewriteRule ^video$ /videos.php/$1 [L]
RewriteRule ^(.*)$ /index.php/$1 [L]
my logic is if first is matched video in the url redirect to videos.php and forget for all under this line, but seems to be in other way. Can some one to explain how to have some predifined urls and all others to go on index.php, tnx in advanced.
You are getting 500 (Internal server error) because your rule is looping in this rule:
RewriteRule ^(.*)$ /index.php/$1 [L]
To fix this rule have your .htaccess like this:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(index\.php|img|js|css|admin|robots\.txt)
RewriteRule ^video$ /videos.php/$1 [L]
# ignore existing files and directories from rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
I need to rewrite my images urls for better SEO using Timthumb.
I have this htaccess file (on Codeigniter) that It works, but when i past an url rewritten (es. http://www.example.com/products/loremipsum-450x600.jpg) It redirect to: http://www.example.com/resize/timthumb.php?src=http://www.moveshop.com/uploads/loremipsum.jpg&w=450&h=600
Is it possible to rewrite without redirect?
Thanks
--
My htaccess file is:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(products)/(.*)-([0-9]{1,4})x([0-9]{1,4}).(jpg) http://www.example.com/resize/timthumb.php?src=http://www.example.com/uploads/$2.$5&w=$3&h=$4 [R=301,L]
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
If the htaccess file is on the same server as the destination (e.g. www.example.com, then you need to remove the host/scheme from your rule and the R flag:
RewriteRule ^(products)/(.*)-([0-9]{1,4})x([0-9]{1,4}).(jpg) /resize/timthumb.php?src=http://www.example.com/uploads/$2.$5&w=$3&h=$4 [L]
If they are not on the same server, then you need to reverse proxy, which means you must have mod_proxy loaded. You'll just need to replace the R flag with the P flag:
RewriteRule ^(products)/(.*)-([0-9]{1,4})x([0-9]{1,4}).(jpg) http://www.example.com/resize/timthumb.php?src=http://www.example.com/uploads/$2.$5&w=$3&h=$4 [P,L]
First off I am using the Codeigniter Framework so this issue is a workaround the way CI process URLs along with the current redirects I have set up using mod_rewrite.
I am trying to get a URL like this /?gclid=somestringgoeshere to redirect to /index.php?/home/gclid/somestringgoeshere.
The current .htaccess I have set is below
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^_]+)-([^_]+)-([^_]+)-([^_]+)-([^_]+)-([^_]+)-([^.]+)$ index.php?/$1_$2_$3_$4_$5_$6_$7 [L]
RewriteRule ^([^_]+)-([^_]+)-([^_]+)-([^_]+)-([^_]+)-([^.]+)$ index.php?/$1_$2_$3_$4_$5_$6 [L]
RewriteRule ^([^_]+)-([^_]+)-([^_]+)-([^_]+)-([^.]+)$ index.php?/$1_$2_$3_$4_$5 [L]
RewriteRule ^([^_]+)-([^_]+)-([^_]+)-([^.]+)$ index.php?/$1_$2_$3_$4 [L]
RewriteRule ^([^_]+)-([^_]+)-([^.]+)$ index.php?/$1_$2_$3 [L]
RewriteRule ^([^_]+)-([^.]+)$ index.php?/$1_$2 [L]
# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# This last condition enables access to the images and css folders, and the robots.txt file
# Submitted by Michael Radlmaier (mradlmaier)
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
I am trying to use the following code right above the first set up rewrite conditions and rule's to catch it before it try's anything else
RewriteRule ^?gclid=(.*)$ index.php?/home/gclid/$1 [L]
and
RewriteRule ^\?gclid=(.*)$ index.php?/home/gclid/$1 [L]
and
RewriteRule ^/?gclid=(.*)$ index.php?/home/gclid/$1 [L]
All either don't show the correct page or come up with a 500 internal error.
The URI’s query can only be tested with the RewriteCond directive:
RewriteCond %{QUERY_STRING} ^gclid=(.*)
RewriteRule ^$ index.php?/home/gclid/%1 [L]
Or more general (will consider further query parameters):
RewriteCond %{QUERY_STRING} ^([^&]*&)*gclid=([^&]*)
RewriteRule ^$ index.php?/home/gclid/%2 [L]
Oh, by the way: RewriteCond directives only correspond to the first following RewriteRule directive.