I've got my WordPress installed in /apache_installation/dir1/dir2/wp_dir/ and it's accessed through http://myIp/dir1/dir2/wp_dir/
I'd like the users to view only the url http://myIp/dir1/dir2/ but the files continue being served from the /wp_dir/ subfolder.
I've tried so many choices, all from stackoverflow, and all of them preceded of
php_value magic_quotes 0
php_flag magic_quotes off
php_value magic_quotes_gpc 0
php_flag magic_quotes_gpc off
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?myIp/dir1/dir2/$
RewriteRule !^wp_dir/ /wp_dir%{REQUEST_URI} [L]
or
RewriteRule ^$ wp_dir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ wp_dir/$1
or
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+wp_dir/([^\s]+) [NC]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (?!^wp_dir/)^(.*)$ /dir1/dir2/wp_dir/$1 [L,NC,R=301]
or
RewriteRule ^/wp_dir/(.*)$ http://myIp/dir1/dir2/wp_dir/$1 [L,R=301]
or
RewriteCond %{THE_REQUEST} ^GET\ /wp_dir/
RewriteCond %{HTTP_HOST} ^(www\.)?myIp/dir1/dir2$
RewriteRule ^wp_dir/(.*) /$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?myIp/dir1/dir2$
RewriteRule !^wp_dir/ wp_dir%{REQUEST_URI} [L]
or
RewriteRule !^wp_dir/ /dir1/dir2/wp_dir%{REQUEST_URI} [L,NC]
or
RewriteCond %{REQUEST_URI} !^wp_dir/
RewriteRule ^(.*)$ wp_dir/$1 [L]
or
RewriteCond %{HTTP_HOST} ([^/]+)\.myIp.*
RewriteCond %{REQUEST_URI} ^/([^/]+)$
RewriteRule .* http://myIp/dir1/dir2/wp_dir/%2 [L]
or
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+wp_dir/([^\s]+) [NC]
RewriteRule ^ %1 [R=301,L]
or
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (?!^wp_dir/)^(.*)$ /dir1/dir2/wp_dir/$1 [L,NC]
and followed by
ErrorDocument 404 /404page.php
Inside wp_dir, there's another htaccess (generated by wordpress) with the code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /dir1/dir2/wp_dir/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /dir1/dir2/wp_dir/index.php [L]
</IfModule>
I've touched nothing in it.
None of the root htaccess choices work for me, everyone with different errors. Some of them gives a "Not found" error, other displays the core of the wordpress site but with the content of the 404 page.
I'm stuck at this point, as you can see I'm not used to this file.
It seems that your entire site is in the wordpress folder - what you could maybe do is copy all of the files inside the main folder, and paste them in the root folder - afterward deleting the wordpress folder.
Related
I have WP and Laravel6 with structure.
my_site/
.htaccess
wp/
laravel/.htaccess
and virtualhost
<VirtualHost subdomain.local:777>
DocumentRoot "c:\xampp\htdocs\my_site"
ServerName subdomain.local
</VirtualHost>
As I want to serve landing page from WP, I do bit changes in root .htaccess to remove wp from url
RewriteEngine on
# remove wp from urls
RewriteCond %{HTTP_HOST} ^subdomain.local:777$
RewriteCond %{REQUEST_URI} !^/wp/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wp/$1
RewriteCond %{HTTP_HOST} ^subdomain.local:777$
RewriteRule ^(/)?$ wp/index.php [L]
now subdomain.local:777 shows wp landing page.
Next I want to eliminate laravel folder from urls which are serving from laravel ie:
subdomain.local:777/laravel/login to subdomain.local:777/login
subdomain.local:777/laravel/profile to subdomain.local:777/profile
and so on..
for that I add following into laravel/.htaccess but it crash all routes..
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^laravel/(.*)$ /$1 [L,NC,R]
with error
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
subdomain.local
Apache/2.4.37 (Win32) OpenSSL/1.1.1 PHP/7.2.12
additionally my laravel/.htaccess file also configuring css/js/image/fonts to work like so
Options -MultiViews -Indexes
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt|\.woff|\.woff2|\.ttf)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|images|google_map|image_compressor|admin-files|fontawesome-free|webfonts)/(.*)$ public/$1/$2 [L,NC]
or do I need to edit in c:\xampp\apache\conf\httpd.conf
Finally solved by bit changes in root .htaccess. such that the final version of .htaccess is now
RewriteEngine on
# remove wp from urls
RewriteCond %{HTTP_HOST} ^subdomain.local:777$
RewriteCond %{REQUEST_URI} !^/wp/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wp/$1
RewriteCond %{HTTP_HOST} ^subdomain.local:777$
RewriteRule ^(/)?$ wp/index.php [L]
# Rewrite Laravel Routes
RewriteCond %{REQUEST_URI} !^/login [OR]
RewriteCond %{REQUEST_URI} !^/profile
RewriteRule ^(.*)$ laravel/public/$1 [L]
haberimyok.com/tr doesnt work,
haberimyok.com/tr/ works.
.htaccess is in the /web/tr directory
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?haberimyok.com$
RewriteCond %{REQUEST_URI} !^/web/tr
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /web/tr/$1
RewriteCond %{HTTP_HOST} ^(www.)?haberimyok.com$
RewriteRule ^(/)?$ index.php [L]
</IfModule>
Thank you.
i have my main site with the next .htaccess
# To externally redirect /dir/file.php to /dir/file
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.+?)\.php[\s?]
RewriteRule ^ /%1 [R=301,L,NE]
# To internally forward /dir/file to /dir/file.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ /$1.php [L]
and in my subdomain i just install wordpress, but the rewrite rules of my main site broke the navigation of my wordpress, how can exclude my subdomain from the rules of my main domain?
i am try this but dont work
# don't apply any rewrites to the subdomain
RewriteCond %{HTTP_HOST} ^subdomain\.mysite\.com$
RewriteRule .* - [L]
and in the .htaccess of my wordpress forlder i have this
# 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
any idea how can fix this?
thanks in advance
Use in your main site .htaccess
# To externally redirect /dir/file.php to /dir/file
RewriteCond %{HTTP_HOST} !^subdomain\.mysite\.com$ [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.+?)\.php[\s?]
RewriteRule ^ /%1 [R=301,L,NE]
# To internally forward /dir/file to /dir/file.php
RewriteCond %{HTTP_HOST} !^subdomain\.mysite\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ /$1.php [L]
I already have some url redirect rule in my root htaccess so after following the step to give wordpress its own directory everything work well apart that my old url redirection/rewrite don't work any more.
old htaccess
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule dailylife/(.*)\.html dailylife.php?d=$1
new one with wordpress directory
RewriteBase /news/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /news/index.php [L]
RewriteRule dailylife/(.*)\.html dailylife.php?d=$1
any help most welcome
You need to have your old rules before wordpress' routing rules:
RewriteBase /news/
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteRule dailylife/(.*)\.html /dailylife.php?d=$1 [L]
RewriteBase /news/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /news/index.php [L]
I would like to make a simple URL rewrite but can not succeed... Here is what I have:
I have 3 websites on the same hosting.
www.websiteAAA.com - a regular website, located in '/website-AAA-folder' folder
www.websiteBBB.com - a regular website, located in '/website-BBB-folder' folder
www.websiteCCC-Wordpress.com - a Wordpress website, , located in '/website-CCC-Wordpress-folder' folder
I order to redirect the requests to the correct domain-filder I have an .htaccess file in the main directory:
Options +SymLinksIfOwnerMatch AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
#redirect to the correct folder
RewriteCond %{HTTP_HOST} websiteAAA.com$ [NC]
RewriteCond %{REQUEST_URI} !^/website-AAA-folder/.*$
RewriteRule ^(.*)$ /website-AAA-folder/$1 [L]
#redirect to the correct folder
RewriteCond %{HTTP_HOST} websiteBBB.com$ [NC]
RewriteCond %{REQUEST_URI} !^/website-BBB-folder/.*$
RewriteRule ^(.*)$ /website-BBB-folder/$1 [L]
#redirect to the correct folder
RewriteCond %{HTTP_HOST} websiteCCC-Wordpress.com$ [NC]
RewriteCond %{REQUEST_URI} !^/website-CCC-Wordpress-folder/.*$
RewriteRule ^(.*)$ /website-AAA-folder/$1 [L]
in /website-CCC-Wordpress-folder/ (where the wordpress site is), there is an additional .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I woulde like to rewite www.websiteCCC-Wordpress.com/aaa/ to www.websiteCCC-Wordpress.com/?id=2&someugleurl=e&blabla=1
I add this line to my .htaccess file that is in the root folder:
RewriteRule ^(aaa)$ ?id=2&someugleurl=e&blabla=1 [L]
However, that does not work.
Please advice.
Thanks
Figured it out
You have to put the line
RewriteRule ^(aaa)$ ?id=2&someugleurl=e&blabla=1 [L]
to be first in the htaccess file in wordpress
RewriteRule ^(aaa)$ ?id=2&someugleurl=e&blabla=1 [L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>