I have a php site in the root folder with an htaccess. I have a blog in a subfolder but the wordpress blog is not loading because of the blog htaccess is conflicting with the htaccess in the root folder.
Here is the two htaccess files
Root Folder
#Options +FollowSymLinks
Options -Multiviews
RewriteEngine on
#RewriteBase /lasercap/public_html/
RewriteCond %{REQUEST_URI} !^/blog/
#Map http://www.example.com/x to /jekyll/x unless there is a x in the web root.
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_URI} !^/lasercap/public_html/
RewriteRule ^ISHRS2013$ ISHRS2013.php
RewriteRule ^(.*)$ /lasercap/public_html/$1
#DirectoryIndex /lasercap/public_html/site-offline.html index.html
DirectoryIndex /lasercap/public_html/index.php
htaccess for Wordpress Blog
<Files .htaccess>
order allow,deny
deny from all
</Files>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/blog/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/failed_auth.html$
RewriteRule ^.*$ - [L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
Can anyone help with htaccess. i need your help. Thank you
Related
I'm currently trying to achieve this using .htaccess
http://example.com - using public_html folder
http://example.com/places - using the places folder
This is the current structure of my folders and also both public_html and places folder are a wordpress site
root
|-public_html
|-places
| |-.htaccess
|-.htaccess
root/.htaccess
RewriteEngine on
RewriteCond ${HTTP_HOST} ^example.com$ [NC,OR]
RewriteCond ${HTTP_HOST} ^www.example.com$
RewriteCond ${REQUEST_URI} !public_html/
RewriteRule (.*) /public_html/$1 [L]
# This is a must
# 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
root/places/.htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /places/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /places/index.php [L]
</IfModule>
# END WordPress
Here is my folder structure
www.mywebsite.com
www.mywebsite.com/app
www.mywebsite.com/app/firstproject
www.mywebsite.com/app/secondtproject
In the root directory i installed wordpress. It allows me to access the www.mywebsite.com/app but when i try to access the www.mywebsite.com/app it is always showing page not found i can guess that it is because of the .htaccess at the root folder.
Here is the .htaccess root folder
# 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
I tried to override the .htaccess to the sub folders by having the below code in the .htaccess of the app folder but it shows the same page not found error.
RewriteRule ^app/ - [L]
How can i access the www.mywebsite.com/app/firstproject without that error ?
Remove app/.htaccess
Have this code in root .htaccess:
root .htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(index\.php$|app/) - [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress
Write all rules in the root htaccess file.
add
RewriteRule ^app/firstproject$ - [L]
to prevent rewrite in this path.
For further rewrite within /firstproject, you need conditions and rules similar to web root
RewriteEngine On
RewriteBase /
RewriteRule ^app/firstproject$ - [L] #add longer path first
RewriteRule ^index.php$ - [L] #no need to escape \.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
I'm trying to make a subdirectory on wordpress
http://wpsite.com/codeigniter,
http://wpsite.com/someothersubdir
But when I go to that url, it always redirects back to the wordpress site with the "page not found"
Here is the wordpress root htaccess file
# -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>
# 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
How can I make sub directories separate from wordpress? Thank you
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/codeigniter/
RewriteCond %{REQUEST_URI} !^/someothersubdir/
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
In my case the issue was in the htaccess of the subfolder (where I have another wordpress running, for testing purposes). So I had to change the .htaccess of the subfolder to this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /someothersubdir
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
My wordpress blog is installed in a subfoler : /wp/. I have create a subfolder in in the directory of the theme used : /test/
But when I try to access by the url : http//www.domain.com/wp/test/. I have an error 404
My .htaccess in wordpress root directory:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp/
RewriteCond %{REQUEST_URI} ^/test/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>
# END WordPress
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php
</IfModule>
# END WordPress
My .htaccess in \test\ folder:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/test/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php [L]
</IfModule>
ry replacing your rule with this:
RewriteRule ^test(/|$) - [L,NC]
An obsolete Wordpress image plugin has left me with over 4000 404 errors.
To solve the problem, I'd like to batch 301 redirect thousands of old attachment link URLs to point towards the original source image files:
The old URLs that give a 404 error look like this:
http://www.hongkonghustle.com/?pagename=album&?pp_album=main&pp_cat=default&pp_image=zombie_boy_tattoo_lady_gaga_rick_genest.jpg
I'd like to redirect them each to the wp-content/photos directory where the file actually exists:
http://www.hongkonghustle.com/wp-content/photos/zombie_boy_tattoo_lady_gaga_rick_genest.jpg
From what I've read, I believe I should alter my htaccess file and add a RewriteCond using the {QUERY_STRING} but I don't know exactly how.
Also, where should I put the changes relative to my current htaccess?
My current htaccess file includes the following:
Options +Indexes
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^hongkonghustle\.com
RewriteRule ^(.*)$ http://www.hongkonghustle.com/$1 [R=permanent,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.hongkonghustle.com/$1/ [L,R=301]
RewriteEngine On
RewriteBase /
<Files wp-config.php>
Deny from all
</Files>
<Files wp-config.php>
Deny from all
</Files>
Options +Indexes
IndexOptions -FancyIndexing
# 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
Thanks again Anubhava! You're getting very close!
Now it goes to the /wp-content/photos/ directory, but the URL is still incorrect:
hongkonghustle.com/wp-content/photos/&/?pagename=album&%253fpp_album=main&pp_cat=default&pp_image=zombie_boy_tattoo_lady_gaga_rick_genest.jpg
We need the final URL to be:
hongkonghustle.com/wp-content/photos/zombie_boy_tattoo_lady_gaga_rick_genest.jpg
So, hongkonghustle.com/wp-content/photos/IMAGE_FILENAME.JPG
I think it's almost solved! Please update me if you have any ideas on how to accomplish this. Sincere thanks!
I ended up doing a 301 redirect like this in htaccess:
Options +Indexes
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} ^pagename=album&\??pp_album=main&pp_cat=default&pp_image=(.*)$
RewriteRule .* /wp-content/photos/%1? [L,R=301]
RewriteCond %{HTTP_HOST} ^hongkonghustle\.com
RewriteRule ^(.*)$ http://www.hongkonghustle.com/$1 [R=permanent,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.hongkonghustle.com/$1/ [L,R=301]
RewriteEngine On
RewriteBase /
<Files wp-config.php>
Deny from all
</Files>
<Files wp-config.php>
Deny from all
</Files>
Options +Indexes
IndexOptions -FancyIndexing
# 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
Change your code to this:
Options +Indexes +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} (^|&)pp_image=([^&]+) [NC]
RewriteRule ^$ /wp-content/photos/%1 [R=301,L]
RewriteCond %{HTTP_HOST} ^hongkonghustle\.com$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^ %{REQUEST_URI}/ [L,R=301]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
<Files wp-config.php>
Deny from all
</Files>
IndexOptions -FancyIndexing