I wrote rules to rewrite url
RewriteRule ^([a-zA-Z0-9-/]+)$ news.php?id=$1
RewriteRule ^([a-zA-Z0-9-/]+)/$ news.php?id=$1
but I need that http://mysite.com/blog/ not to be rewritten by these rules.
Thanks for you advices :).
My .htaccess file:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !news\.php [NC]
RewriteCond %{REQUEST_URI} !/blog [NC]
RewriteCond %{REQUEST_URI} ^/([^/]+) [NC]
RewriteRule .* news.php?id=%1 [R=301,L]
RewriteRule ^video_([^/]+) video.php?page=Video&table=$1
RewriteRule ^en/([a-zA-Z0-9-/]+)$ en/news_en.php?no=$1
RewriteRule ^en/([a-zA-Z0-9-/]+)/$ en/news_en.php?no=$1
RewriteRule ^it/([a-zA-Z0-9-/]+)$ it/news.php?id=$1
RewriteRule ^it/([a-zA-Z0-9-/]+)/$ it/news.php?id=$1
RewriteRule ^photo_([^/]+) photogalery.php?page=Photo&part=$1
RewriteRule ^en/photo_([^/]+) en/photogalery.php?page=Photo&part=$1
RewriteRule ^it/photo_([^/]+) it/photogalery.php?page=Photo&part=$1
ErrorDocument 404 /404.html
use
RewriteEngine On
RewriteRule ^blog/([a-zA-Z0-9_-]+)$ news.php?id=$1
Related
so I got this script from codester and I wasn't able to install it cause I keep getting errors like ".htaccess misconfigured" can anyone detect the error for me please, here is the .htaccess code
RewriteEngine on
RewwriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^(.+?)/$ /$1 [R=301,L]
RewriteRule page/(.*)$ page.php?slug=$1 [L]
RewriteRule py$ _py.php [L]
RewriteRule payout$ pyt.php [L]
RewriteRule contact$ ct.php [L]
Options -Indexes
ErrorDocument 404 /404.php
Help
There is a spelling mistake in your second line, use
RewriteBase /
instead of RewwriteBase /
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^(.+?)/$ /$1 [R=301,L]
RewriteRule page/(.*)$ page.php?slug=$1 [L]
RewriteRule py$ _py.php [L]
RewriteRule payout$ pyt.php [L]
RewriteRule contact$ ct.php [L]
Options -Indexes
ErrorDocument 404 /404.php
I have the following htaccess file. I do not want to perform a redirect from https to http on a certain file. how can i achieve this?
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.spectrumasa.com$ [NC]
RewriteRule ^(.*)$ http://www.spectrumgeo.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^intranet.spectrumasa.com$ [NC]
RewriteRule ^(.*)$ http://www.spectrumgeo.com/ [R=302,L]
RewriteCond %{HTTP_HOST} ^www.asb.com.au$ [NC]
RewriteRule ^(.*)$ http://www.spectrumgeo.com/ [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.spectrum-geopex\.com\.eg$ [NC]
RewriteRule ^(.*)$ http://www.spectrumgeo.com/spectrum-geopex [R=301,L]
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/server-status
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I would like to access only the following through https http://www.spectrumgeo.com/wp-content/uploads/Spectrum_logo_email-171w.jpg
Add a condition to your rule:
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/wp-content/uploads/Spectrum_logo_email-171w\.jpg$
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
You can have something complex in picking with to redirect to https:// from http:// but you can accomplish a simple redirect on a single file via this method.
RewriteEngine
Redirect http://www.spectrumgeo.com/wp-content/uploads/Spectrum_logo_email-171w.jpg https://www.spectrumgeo.com/wp-content/uploads/Spectrum_logo_email-171w.jpg
This will solve accessing only the above url you have through https://
I am having a issue with my urls google have crawled double http for example
http://example.com/example.com/c-title-id.html
and all the interlinked pages like that
please can any one help me out to redirect all the urls with 301 with .htacess
My htacess code is
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.website\.com [NC]
RewriteRule ^(.*)$ http://website.com/$1 [L,R=301]
RewriteRule category-([0-9]+)-(.*)-([0-9]+)\.html$ category.php?cid=$1&name=$2&page=$3.php [L]
RewriteRule search-(.*)-([0-9]+)\.html$ search.php?term=$1&page=$2.php [L]
RewriteRule all-covers-([0-9]+)\.html$ all-covers.php?page=$1.php [L]
RewriteRule index-([0-9]+)\.html$ index.php?page=$1.php [L]
RewriteRule featured-covers-([0-9]+)\.html$ featured-covers.php?page=$1.php [L]
RewriteRule top-downloaded-([0-9]+)\.html$ top-downloaded.php?page=$1.php [L]
RewriteRule c-([0-9]+)(.*)\.html$ cover.php?id=$1&name=$2.php [L]
RewriteRule sitemap.xml$ sitemap.php [L]
RewriteRule sitemap1.xml$ sitemap1.php [L]
RewriteRule rss.xml$ rss.php [L]
RewriteRule ^(.*)\.html$ $1.php [L]
ErrorDocument 404 /404.html
I want to redirect all of them automaticaly.
Should be as simple as having this at the top of your rules:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.website\.com [NC]
RewriteRule ^(.*)$ http://website.com/$1 [L,R=301]
RewriteRule example\.com/(.*)$ /$1 [R=301,L]
#... rest of your rules...
I want to redirect the url:
http://www.mysite.com/invite/YhMck/en
to
http://www.mysite.com/auth/accept_invite/YhMck/en
can any please help me with the RewiteRule
RewriteCond %{HTTP_HOST} ^mysite.com/invite/YhMck/en
RewriteRule (.*) http://www.mysite.com/auth/accept_invite/YhMck/en/$1 [R=301,L]
RewriteEngine On
add this to your .htaccess in your documentroot
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} ^/invite
RewriteRule ^invite/([^/]+)/(\w{2})$ auth/accept_invite/$1/$2
from comments:
These rules:
RewriteCond $1 !^(index\.php|robots\.txt|images|img|css|js|fonts)
RewriteRule ^(.*)$ /index.php/$1 [L]
Will add index.php to every rule that does not begin with index.php|robots\.txt|images|img|css|js|fonts
So your /invite would also have been re-written to /index.php/invite...
Try this in the same order
RewriteEngine on
RewriteBase /
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} ^/invite
RewriteRule ^invite/([^/]+)/(\w{2})$ auth/accept_invite/$1/$2 [L]
RewriteCond $1 !^(auth/|index\.php|robots\.txt|images|img|css|js|fonts)
RewriteRule ^(.*)$ /index.php/$1 [L]
I have this .htaccess:
RewriteEngine On
RewriteRule ^!/(.*)$ path/to/a/file/$1 [L]
RewriteRule ^(.*)$ path/to/another/file/$1 [L]
I want urls in the form of www.website.com/!/this/ to be rewritten to path/to/a/file. Any URL that doesn't match that pattern should be rewritten to path/to/another/file/.
Here's what I've tried to far:
RewriteEngine On
RewriteRule ^!/(.*)$ path/to/a/file/$1 [L]
RewriteCond ...
RewriteRule ^(.*)$ path/to/another/file/$1 [L]
When using the above rewrite rule, I get a 500 - Internal Error.
How can I fix it?
Try this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/!
RewriteRule ^!/([a-z0-9_\-\.]+) user/public/$1 [L]
RewriteCond %{REQUEST_URI} !^/!
RewriteRule ^([a-z0-9_\-\.]+)/([a-z0-9_\-\.]+)/?$ $1/controller/front.php/$2 [L]
RewriteCond %{REQUEST_URI} !^/!
RewriteRule ^([a-z0-9_\-]+)/([a-z0-9_\-]+)/([a-z0-9_\-]+)/?$ $1/controller/front.php/$2/$3 [L]