Thanks in advance to all you .htaccess guru's out there. I'm having an issue that's been bothering me for some time. I have wordpress nested inside my own site folder structure. To the user, everything is cool. But when i go to www.domain.com/blog/wp-admin, my credentials will not log in. It just keeps looping me around to the same page. If I go to www.domain.com/blog/wp-login.php directly it works. I wonder if anyone knows why this is.
The blog is located at /fe/blog/.
The .htaccess in / is:
Options +FollowSymlinks -Indexes
RewriteEngine on
RewriteRule ^(files)/?(.*) /files/$2 [NC,L]
RewriteRule ^(.*) /fe/$1 [NC]
The .htaccess in /fe is:
Options +FollowSymlinks -Indexes
RewriteEngine on
And Finally the .htaccess in the /fe/blog/ is:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
Any help would be greatly appreciated!
Try this in your /.htaccess file:
RewriteEngine on
RewriteRule !^(files|fe)/ fe%{REQUEST_URI} [NC]
And this in your /fe/blog/.htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
i wonder if this line is not the culprit:
RewriteRule ^(files)/?(.*) /files/$2 [NC,L]
could you try:
RewriteRule ^files/?(.*) /files/$1 [NC,L]
If not, you might also add the flag [QSA] (Query String Append)
RewriteRule ^files/?(.*) /files/$1 [NC,L, QSA]
Related
I would appreciate if someone can help with this mod rewrite issue. For years I had this in my htaccess, apache include files and it worked just fine.
RewriteRule ^/article/([0-9]*).html$ /article/article.php?id=$1 [NC,L]
But recently it stopped working. Browser shows "No input file specified." and access log shows 404 response code the requests that had to be fulfilled by the condition above.
RewriteEngine is on. This is what my htaccess mod_rewrite rules at the moment
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) /404error.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^/article/([0-9]*).html$ /article/article.php?id=$1 [NC,L]
RewriteRule ^/relationships/([0-9]*).html$ /article/article.php?id=$1 [NC,L]
</IfModule>
With your shown samples/attempts, could you please try following htaccess Rules. Please make sure to place your htaccess rules file in root and clear your browser cache before testing your URLs.
<IfModule mod_rewrite.c>
Options -MultiViews -Indexes
RewriteEngine On
RewriteBase /
##Rules for non-existing pages.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
##Rules for articile and relationship uris here.
RewriteRule ^(?:article|relationships)/([0-9]*)\.html/?$ article/article.php?id=$1 [NC,L]
##Rules for 404 handling.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) 404error.php [L,NC]
</IfModule>
I have two page and I'm trying to make good looking url for these links.
First link :-
http://www.themobilesapp.com/tags.php?tag=Android
for to convert this url into this url.
http://www.themobilesapp.com/tag/Android
for this i write this code.
RewriteRule ^tag/([A-Za-z0-9-]+)?$ tags.php?tag=$1 [L]
Second link :-
http://www.themobilesapp.com/phones.php?title=Apple
for to convert this url into this url.
http://www.themobilesapp.com/brand/Android
for this i write this code.
RewriteRule ^brand/([A-Za-z0-9-]+)?$ phones.php?title=$1 [L]
But on both pages one same error is coming.
This error is coming on my page
Internal Server Error
and my whole htaccess file code is
Options +FollowSymLinks -MultiViews -Indexes
Options -Multiviews
<IfModule mod_rewrite.c>
DirectoryIndex index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
ErrorDocument 404 404error.php
RewriteRule ^([A-Za-z0-9-]+)?$ specification.php?url=$1 [L]
RewriteRule ^news/([A-Za-z0-9-]+)?$ news.php?url=$1 [L]
RewriteRule ^social/([A-Za-z0-9-]+)?$ social.php?url=$1 [L]
RewriteRule ^tag/([A-Za-z0-9-]+)?$ tags.php?tag=$1 [L]
RewriteRule ^brand/([A-Za-z0-9-]+)?$ phones.php?title=$1 [L]
</IfModule>
All RewriteRule rules are working except below two.
Please check for spellings and make sure file exist, try to use below simplified rule.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#after above rewrite cond use below rewrite for each page in below manner
RewriteRule ^tags/([\w-]+)$ tags.php?tag=$1 [L]
For some reason stylesheets and images are not loading on my site :(
Don't really know why I believe it may be to do with my htaccess file here is how it currently is.
UPDATE - NEW FILE
#SetEnv APPLICATION_ENV development
DirectoryIndex /public/index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.+) $1 [L]
RewriteCond %{DOCUMENT_ROOT}/public%{REQUEST_URI} -f
RewriteRule ^(.+) /public/$1 [L]
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /public/index.php?q=$1 [L,QSA]
RewriteRule !\.(js|ico|gif|jpg|png|css|xml|xslt)$ /public/index.php
Any idea why its not loading?
It looks like there has been some cut-and-pasting: 'RewriteEngine on' should be there only once and the code from that point is causing you trouble.
The reasons for those lines are not clear without more info on the kind of site you run, so any advice from here is trial and error testing:
The last rule is commented out and looks like an effort to get the stylesheet and images (all js|ico|gif|jpg|png|css|xml|xslt files) correctly rewritten to the desired address. You can try to comment it out (get rid of the #).
The problem was fixed by rewriting the whole file to the following
DirectoryIndex /public/index.php
RewriteEngine On
Options +FollowSymLinks -MultiViews -Indexes
RewriteBase /public
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(domainUrlNoHttp)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^http://(domainUrl)$
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]
I've read been reading StackOverflow posts for the last 30 minutes and none of them work. Maybe there is a server setup that is preventing this from working?
I just want to remove index.php from whatever URL is typed in. For example, www.mysite.com/blah/blah/index.php would become www.mysite.com/blah/blah/. www.mysite.com/index.php would become www.mysite.com/.
I've read at least 10 posts and tried each one, but it ALWAYS just redirects to the root. Here is the current code I'm using that looks like it should work:
Options +FollowSymLinks
Options +Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>
Instead of just removing index.php from the URL, it redirects to the root of the site.
I think this is what you are looking for:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ $1/index.php [L,QSA]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php($|\ |\?)
RewriteRule ^ /%1 [R=301,L]
</IfModule>
My site is a php based site, but I've added wordpress in a /blog/ folder. The .htaccess file below should allow the /blog/ folder to be accessed, but I get a 404 error saying that blog.php doesn't exist.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !\.(gif|jpg|png)$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/(.*)/$ /$1_$2.php [L]
RewriteRule ^(.*)/$ /$1.php [L]
</IfModule>
Anybody able to help at all?
The last RewriteRule is redirecting your request to /blog/ to index.php, you should add a RewriteCond to check if the request is on the blog folder.
RewriteCond %{REQUEST_URI} !^/blog/.*
I managed this using the code below, for some reason the conditionals that were suggested don't work (I HATE .htaccess)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(blog) - [L]
RewriteCond %{SCRIPT_FILENAME} !\.(gif|jpg|png)$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/(.*)/$ /$1_$2.php [L]
RewriteRule ^(.*)/$ /$1.php [L]
</IfModule>
Adding
RewriteRule ^(blog) - [L]
to public_html/.htaccess after
RewriteEngine On
worked for me as well on a fresh Wordpress installation with Fantastico on a Hostgator account, with a blog.example.com subdomain.