two htaccess files in one website - .htaccess

I created a website in Expression Web and in the website I created a subfolder with my blog which was created in Wordpress. I am not sure if having two different platforms create a problem when crawling my site with Google.
I have two .htaccess files:
one in the root directory which is:
XBitHack on
AddHandler server-parsed .htm
rewriteengine on
rewritecond %{HTTP_HOST} ^mysite.com$
rewriterule ^(.*)$ "http\:\/\/www\.mysite\.com\/$1" [R=301,L] #4d73215aa0571
# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName www.mysite.com
AuthUserFile /var/chroot/home/content/i/r/m/irmarie/html/_vti_pvt/service.pwd
AuthGroupFile /var/chroot/home/content/i/r/m/irmarie/html/_vti_pvt/service.grp
Options +FollowSymLinks
rewritecond %{HTTP_HOST} ^mysite\.com$ [NC]
rewriterule ^(.*)$ http://www.mysite.com/$1 [R=301,L]
One .htaccess file in the subfolder of my wordpress blog.
Which is:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
In my site I have many subfolders such as:
folder_a
folder_b
folder_c
When checking my Google crawl stats it looks like Google is looping and creating pages that look like this:
root/folder_a/folder_b/folder_c/folder_d.htm
and adding an htm extension at the end and showing as a 404 page.
This goes on and on in a never ending loop and therefore googlebot stops crawling the rest of my site.
I will appreciate if someone could help me in solving this issue.
Thanks

Related

.htaccess redirect URL with specific query string parameter, compatibility with multiple servers

I want to rewrite this specific URL:
https://www.domain.test/cart/?query_action=abc
...to this URL:
https://www.domain.test/cart/
The "abc" part is variable, everything else is exactly what I want to rewrite. I added these lines to my .htaccess file:
RewriteCond %{QUERY_STRING} ^query_action\=
RewriteRule ^folder/$ /folder/? [L]
When I run this on my local environment, it works. But when I upload to our development server (WP Engine), it does not work. Are there incompatibilities with .htaccess between different servers? Does my code's proximity with WordPress' default code have anything to do with it? Is there something I can tweak in my rewrite to improve it?
Here is my entire .htaccess file:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^query_action\=
RewriteRule ^folder/$ /folder/? [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
<Files xmlrpc.php>
order deny,allow
deny from all
</Files>

.htaccess redirect & hide directory path in url

I have wordpress installed in root directory. I want to use some separate php files as a page on my domain, for which I have made a separate directory which holds all files for serving the php files, of which the directory structure is as:
the root folder has all the wordpress files
the directory which I'd like to serve as a page
/inc/css/
/inc/php/
/inc/img/
the CSS stylesheet files directory location in the PHP file is ../inc/css one step back & then css folder.
I want to hide folders from URL such as the files are served from the root (hide the /inc/php/, /inc/css/ & /inc/img/ folders from URL).
eg: www.domain.com/inc/php/about.php redirect & rewrite this URL to www.domain.com/about
the .htaccess in my root
RewriteEngine On
RewriteBase /
# disable directory browsing
Options -Indexes
# Prevent hotlinking of images htaccesstools.com/hotlink-protection
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain.com [NC]
RewriteRule \.(jpg|jpeg|png|gif|ico|pdf|flv|jpg|jpeg|mp3|mpg|mp4|mov|wav|wmv|png|gif|swf|css|js)$ - [NC,F,L]
RewriteRule ^login$ http://domain.com/wp-login.php [NC,L]
# 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
<files wp-config.php>
order allow,deny
deny from all
</files>
<files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</files>
I have tried the simple redirect rule but the folders are exposed in the URL.
Redirect 301 /about.php /inc/php/about.php
also I have some more files in the PHP folder on which I'd like to apply the same rule of redirect & rewrite URL & hide folders from URL & remove the PHP extention.
www.domain.com/inc/php/about.php redirect & rewrite this URL to www.domain.com/about
This, of course, means that you can't have the same base filename that's a php file and, say, a css file. Since if the request is www.domain.com/about, is that supposed to map to /inc/php/about.php or /inc/css/about.css? Or is it an image? If you have both files, only one will get mapped to.
But if that's really what you want, try adding these rules right after the hotlinking rule that you have:
# Externally redirect requests for /inc/
RewriteCond %{THE_REQUEST} \ /inc/(php|img|css)/([^\?\ ]+)\.(php|css|jpe?g|png|gif) [NC]
RewriteRule ^ /%2 [L,R=301]
# Check if the request is a php file:
RewriteCond %{DOCUMENT_ROOT}/inc/php%{REQUEST_URI}.php -f
RewriteRule ^(.*)$ /inc/php/$1.php [L]
# Check if the request is a css file:
RewriteCond %{DOCUMENT_ROOT}/inc/css%{REQUEST_URI}.css -f
RewriteRule ^(.*)$ /inc/css/$1.css [L]
# Check if the request is a jpeg file:
RewriteCond %{DOCUMENT_ROOT}/inc/img%{REQUEST_URI}.jpg -f
RewriteRule ^(.*)$ /inc/img/$1.jpg [L]
# Check if the request is a gif file:
RewriteCond %{DOCUMENT_ROOT}/inc/img%{REQUEST_URI}.gif -f
RewriteRule ^(.*)$ /inc/img/$1.gif [L]
# Check if the request is a png file:
RewriteCond %{DOCUMENT_ROOT}/inc/img%{REQUEST_URI}.png -f
RewriteRule ^(.*)$ /inc/img/$1.png [L]

Rewriterule on .htaccess leads to 404

I am developing an application that's hosted on an apache server with PHP 5.
There is a website already running on the domain: www.domain.com. My application is on a folder called 'hotsite', and it can be accessed by the url www.domain.com/hotsite/.
The root folder contains a .htaccess containing:
/.htaccess:
XBitHack Off
RewriteEngine On
RewriteCond %{REQUEST_URI} \/([0-9a-z]{6})$ [NC]
RewriteRule ^(.*) http://www.domain.com/url/forward.php?%1 [L]
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName www.domain.com
AuthUserFile /home/intera/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/intera/public_html/_vti_pvt/service.grp
RedirectMatch permanent ^/webmail$ http://http://mail.google.com/hosted/domain.com www.domain.com/hotsite/
In this 'hotsite' folder, there's a .htaccess file containing the following code:
/hotsite/.htaccess:
RewriteEngine on
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ /folder/index.php
Now, when I access www.domain.com/hotsite/, my application loads fine. but when I try and access www.domain.com/hotsite/section/, it appears to ignore the .htaccess file and tries to access "section" as if it was a folder, returning a 404 error.
Any ideias why this is happening and what should I do to make it work?
Thanks =)
If the htaccess is inside the hotsite folder, then RewriteBase / needs to be RewriteBase /hotsite
Just in case; Note that the rewriterule, rewrites to /folder/index.php, and not /hotsite/folder/index.php

vanity url for own site

Hello i tried too much and i coudln't find a solution so i decided to ask here currently iam using wordpress website and my pages and posts link will be www.mydomain.com/postname and i want to make members user profile link like www.mydomain.com/user/profilename must redirect to profile.php?user=Username
Currently iam having this code in .htaccess:
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName sampcnc.com
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
So please help how to do this , Thanks in advance
i want to make members user profile link like www.mydomain.com/user/profilename must redirect to profile.php?user=Username
Before your wordpress rules # BEGIN WordPress, add these:
RewriteEngine On
RewriteRule ^/?user/(.*)$ /profile.php?user=$1 [L,QSA]
So when someone entes www.mydomain.com/user/profilename in their browser's URL address bar, they get served the content at /profile.php?user=profilename. You'll just have to make sure any links you generate look like the /user/profilename version.

mod rewrite in .htaccess to hide url extensions not working

Just can't get rid of my url extensions.
I'm building a static site so all content is in HTML format and files have .html extensions.
I want to hide the .html extensions from users so my url would read websitename.com/about
I have modified the .htaccess file where my site is hosted, it now looks like this
# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName boldfacedesign.co.uk
AuthUserFile /home/boldface/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/boldface/public_html/_vti_pvt/service.grp
RewriteBase /
RewriteEngine on
RewriteCond %{RQUEST_FILENAME} !-d
RewriteCond %{RQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1html [L,QSA]
At present this just isn't working.
As you can see this file is in the public_html folder, is that the correct place for it?
Or is there something else I need to do to enable the rewrite rule to take effect?
Or do I simply need to be patient and wait a day for the changes to take affect?
I've been googling this for hours now and I'm getting nowhere.
Not sure if these are typos or what, but your rewrite rules should probably look more like:
RewriteBase /
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [L,QSA]
Or if you have trailing slashes, the last line should be:
RewriteRule ^(.*?)/?$ $1.html [L,QSA]

Resources