Rewriterule on .htaccess leads to 404 - .htaccess

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

Related

Apache2 rewrite condition with https

I have 2 .htacces file
/usr/local/apache2/htdocs .htacess file with
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteCond %{REQUEST_URI} !^/test2/
RewriteRule ^(.*)$ /test2/$1 [NC,QSA]
/usr/local/apache2/htdocs/test2 .htacess file with
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
RewriteRule !^(ui/|index.php|favicon.ico) - [F,L,NC]
#RewriteCond %{HTTPS} off
#RewriteCond %{REQUEST_URI} !^/admin
#RewriteRule .* https://%{HTTP_HOST}%/admin [L,R=301]
</IfModule>
The application will force the application to the url below while hiding the index.php
http://www.example.com/admin
additionally there is another link with http://www.example.com/display
default directory configured in httpd.conf are :
DocumentRoot "/usr/local/apache2/htdocs/test2"
<Directory "/usr/local/apache2/htdocs/test2"
However if I try to run with https the link
https://www.example.com/admin
I will get this error :
Forbidden
You don't have permission to access /admin/ on this server.
I have tried using the #commented code and still has error. Please help
These problem were fix by applying
I have found out that there are another file, ssl.conf that has a DocumentRoot, fix the problem via adding the same document root in ssl.conf
DocumentRoot "/usr/local/apache2/htdocs/test2"
<Directory "/usr/local/apache2/htdocs/test2"
and
Change a file php.conf to (# was the old code)
# Depreciated in Apache 2.2
# Order allow,deny
# Deny from all
# Satisfy All
# New in Apache 2.4
<RequireAll>
Require valid-user Require ip 127.0.0.1
</RequireAll>

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]

two htaccess files in one website

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

.htaccess not routing to /public_html/

I seem to be having an interesting problem in that .htaccess isn't routing to /public_html/index.html by default as it should, and I'm getting a page not found error. I do know that someone tampered with the file recently but have no idea what they did and I unfortunately know nothing about routing. I tried to do some research but didn't come up with anything that gave a solution to my predicament. Does anyone know how to go about making the server route to public_html? Here's what I have right now.
RewriteEngine on
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 evolvingwebcreations.com
#-------------------------
RewriteCond %{HTTP_HOST} ^swinkapps.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.swinkapps.com$
RewriteRule ^(.*) "http\:\/\/127\.0\.0\.1\:12005\/$1" [P,L]
#-------------------------
RewriteCond %{HTTP_HOST} ^swinkapps.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.swinkapps.com$
RewriteRule ^clients(.*) "http\:\/\/127\.0\.0\.1\:12005\/$1" [P,L]
Thanks in advance!
I don't believe it ever routes to public_html by default. You'll need to specify
UserDir public_html
and possibly set some access permissions such as
<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options Indexes SymLinksIfOwnerMatch IncludesNoExec
</Directory>

Resources