I run a site using Joomla. Backed up to localhost running WAMP, and I have problems with .htaccess. Site is located in /www/sitename/
First, I had to comment out IndexIgnore * to get the site to load at all.
Now, it loads, but if I enable url rewriting, any local link I click on displays a page with my WAMP configuration.
My .htaccess is
Options +FollowSymlinks
Options -Indexes
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\)
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%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]
RewriteBase /
RewriteRule .* index.php [L]
The url is localhost/sitename
Related
I have a site eg: example.com with Lets Encrypt SSL installed. I want to force redirect all url from https to http but at the same time I want the homepage to be force redirect from http to https. Is such thing possible?
Thank you.
My current .htaccess
<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>
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} ^443$ [OR]
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ http://clix2reach.com/$1 [R=301,L]
You can try using this:
RewriteEngine On
RewriteBase /
# Turn HTTPs on for homepage
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/index.php
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
# Turn HTTP on for everything but homepage
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
Change index.php depending on file name / extension.
I need to prevent direct access to a URL (http://www.example.com/gated-asset). Is there any way to add code to the htaccess file that would redirect all direct traffic to another page (http://www.example.com/form)?
I have tried the following code in my htaccess file, but all pages, including the home page, redirect to www.example.com/form.
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://go.example.com [NC]
RewriteRule .* http://www.example.com/form [R,L]
The entire .htaccess file looks like this (it is a WordPress site):
# 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
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://go.example.com [NC]
RewriteRule .* http://www.example.com/form [R,L]
I have also tried the following:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://go.example.com [NC]
RewriteRule ^/$ /form/ [R,L]
RewriteRule ^/$ /gated-asset/ [R,L]
As well as:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://go.example.com [NC]
RewriteRule http://www.example.com/gated-asset http://www.example.com/form/ [R,L]
You need to include http:// in the referrer check if you are matching the beginning (^). Unlike HTTP_HOST, HTTP_REFERER requires it. In addition, the referring URL may include a REQUEST_URI, and so closing the expression at the domain will prevent it from working.
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://go.example.com [NC]
RewriteRule .* http://www.example.com/form [R,L]
If you don't want to include the http://, then you can use the following condition instead:
RewriteCond %{HTTP_REFERER} !go.example.com [NC]
However, I would recommend the first example be used.
Also included here are the R and L flags. R is implied if the rewrite is to an external resource, but it is generally better to include it.
I need to redirect a specific URL (with structure) to a the same URL(s) using a new domain, but not other URLS.
domainA.com/company/careers*
domainB.com/company/careers*
The reason for this is a 3rd party vendor supplying a jquery based iframe app that perfoms a referrer check before loading.
I realize there is a bigger seo/duplicate content issue that needs to be addressed, but there is a lot of additional work that needs to happen before domainA.com is fully redirected to domainB.com so for now, Its only the "career" section.
The site is using IIS6 with HeliconTech's ISAP ReWrite3
http://www.helicontech.com/isapi_rewrite/doc/introduct.htm
Current Rules:
# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.59
<VirtualHost www.domainA.com www.domainB.com>
RewriteEngine On
#RewriteBase /
#RewriteRule ^pubs/(.+)\.pdf$ /404/?pub=$1.pdf [NC,R=301,L]
# Send away some bots
RewriteCond %{HTTP:User-Agent} (?:YodaoBot|Yeti|ZmEu|Morfeus\Scanner) [NC]
RewriteRule .? - [F]
# Ignore dirctories from FarCry Friendly URL processing
RewriteCond %{REQUEST_URI} !(^/measureone|^/blog|^/demo|^/_dev)($|/)
RewriteRule ^([a-zA-Z0-9\/\-\%:\[\]\{\}\|\;\<\>\?\,\*\!\#\#\$\ \(\)\^_`~]*)$ /index.cfm?furl=$1 [L,PT,QSA]
RewriteCond %{REQUEST_URI} ^/company/careers [NC]
RewriteRule ^company/careers/?(.*)$ http://www.domainname.com/company/careers/$1 [R=301,L]
# Allow CFFileServlet requests
RewriteCond %{REQUEST_URI} !(?i)^[\\/]CFFileServlet
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /blog/index.php [L]
</VirtualHost>
<VirtualHost blog.domainA.com>
RewriteEngine On
#redirect old blog.domainA.com/* posts to www.domainB.com/blog/*
RewriteCond %{HTTP_HOST} ^blog.domainA\.com [nc]
RewriteRule (.*) http://www.domainB.com/blog$1 [R=301,L]
</VirtualHost>
It seems that "RewriteBase /blog/" line corrupts your "careers" rule as it implies that the request should be domainA.com/blog/company/careers*
Please consider having it like this:
<VirtualHost www.domainA.com www.domainB.com>
RewriteEngine On
RewriteBase /
#RewriteRule ^pubs/(.+)\.pdf$ /404/?pub=$1.pdf [NC,R=301,L]
# Send away some bots
RewriteCond %{HTTP:User-Agent} (?:YodaoBot|Yeti|ZmEu|Morfeus\Fucking\Scanner) [NC]
RewriteRule .? - [F]
# Ignore dirctories from FarCry Friendly URL processing
RewriteCond %{REQUEST_URI} !(^/measureone|^/blog|^/demo|^/_dev)($|/)
RewriteRule ^([a-zA-Z0-9\/\-\%:\[\]\{\}\|\;\<\>\?\,\*\!\#\#\$\ \(\)\^_`~]*)$ /index.cfm?furl=$1 [L,PT,QSA]
RewriteCond %{REQUEST_URI} ^/company/careers [NC]
RewriteRule ^company/careers/?(.*)$ http://www.domainname.com/company/careers/$1 [R=301,L]
# Allow CFFileServlet requests
RewriteCond %{REQUEST_URI} !(?i)^[\\/]CFFileServlet
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^blog/.* /blog/index.php [L]
</VirtualHost>
If you still have issues, enable logging in httpd.conf by putting
RewriteLogLevel 9
and check how your request is processed in rewrite.log.
Just check to see if the request starts with /company/careers
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/company/careers [NC]
RwriteRule ^company/careers/?(.*)$ http://domainB.com/company/careers/$1 [R=301,L]
See if that works for you.
Curently i've got main site running joomla 1.5 and additional app made on Codeignter in a subfolder.
When i open app index dir url - www.mysite.com/app - it's ok, but if i try to use app deeper, like www.mysite.com/app/controller/view - i get conventional joomla 404 page.
The problem is that rules in joomla .htaccess work for any url that points to real folder on server - for one level but how i can make it NOT_WORK for joomla inside a real subfolder.
Curent joomla htaccess is:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
## Deny access to extension xml files (uncomment out to activate)
#<Files ~ "\.xml$">
#Order allow,deny
#Deny from all
#Satisfy all
#</Files>
## End of deny access to extension xml files
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
You can add RewriteCond %{REQUEST_URI} !^/app to your .htaccess file.
So it looks like this:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} !^/app
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
You also have to add a .htaccess file like this into your app folder:
RewriteEngine on
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /app/index.php/$1 [L]
I have a website with a forum and I am trying to clean up duplicate content issues.
What I am trying to do is 301 redirect any URLS with mywebsite.com/recent-topics/category-title/post-title.html to mywebsite.com/forum/category-title/post-title.html.
It is a Joomla website and a htaccess file is already in use. I have added this string to the end of the htaccess file but it's not working:
RewriteRule ^/recent-topics/(.*) /forum [R=301,L]
Full htaccess file:
RewriteEngine On
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
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]
##
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root).
##
#RewriteBase /
## Begin - Joomla! core SEF Section.
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/component/) [OR]
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
## End - Joomla! core SEF Section.
RewriteRule ^/recent-topics/(.*) /forum [R=301,L]
Can anyone offer any advice as to what I am doing wrong?
You need to add your rule just under the RewriteEngine On. The redirects need to happen before any type of routing happens. The Joomla rules do routing so your rule that redirects to /forum will never get applied.