My client's domain name points to /public_html; his website is at /public_html/wp.
I have a .htaccess that redirects to /public_html/wp:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?somedmain\.com$
RewriteCond %{REQUEST_URI} !^/wp/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wp/$1 [L]
RewriteCond %{HTTP_HOST} ^(www\.)?somedmain\.com$
RewriteRule ^$ /wp/ [L]
However, when the user navigates to a page, the url is displayed as somedmain.com/wp/permalink.
I've been trying to figure how to hide the "wp" in the url; is that possible?
Thanks for any hints....
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]
Installed a fresh Wordpress Website. on clicking http ://mysite.com/wp-admin instead of showing wordpress login page, it shows auth entication required:-
Why may this be?
edit:- my .htaccess file. I don't think it password protects my wp-admin.
rewriteengine on
RewriteCond %{REQUEST_URI} ^.*wp\-login\.php.*$
RewriteCond %{HTTP_COOKIE} !^.*admin_authenticated\=yes.*$
RewriteCond %{REQUEST_URI} !^.*auth.php.*$
rewriterule ^(.*)$ /auth.php?red=%1 [R,L]
rewriterule ^.*auth.php.*$ - [PT]
# 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
remove all this
rewriteengine on
RewriteCond %{REQUEST_URI} ^.*wp\-login\.php.*$
RewriteCond %{HTTP_COOKIE} !^.*admin_authenticated\=yes.*$
RewriteCond %{REQUEST_URI} !^.*auth.php.*$
rewriterule ^(.*)$ /auth.php?red=%1 [R,L]
rewriterule ^.*auth.php.*$ - [PT]
admin_authenticated is requiring a password! And I assume you haven't set up a password yet, or you tried the one you set it up as with username and password, and it didn't work.
So remove all that.
Ok. I'm desperate.
Basically when i add the #Force https lines below it's then sending my shop.mydomain.com/wp-admin to mydomain.com/wp-admin Aaaaaah.
My wordpress shop site lives inside the main domain folder (inside the other wordpress site) i.e. public_html/mydomain(wordpress install)/shop(wordpress install)
I have a Wildcard SSL installed on the www.mydomain.com (which handles 1st level subdomains). The SSL part seems to be working fine.
Here is the .htaccess inside the folder /shop:
#Send www to https
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.shop.mydomain.com$ [NC]
RewriteRule ^(.*)$ https://shop.mydomain.com/$1 [R=301,L]
#Force Https
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# BEGIN WordPress
etc etc
# END WordPress
And inside the main domain folder public_html/mydomain:
#.htaccess WildCard SSL
RewriteEngine On
RewriteCond %{HTTP_HOST} ^shop.mydomain.com$
RewriteCond %{REQUEST_URI} !^/shop/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /shop/$1
RewriteCond %{HTTP_HOST} ^shop.mydomain.com$
RewriteRule ^(/)?$ shop/index.php [L]
# BEGIN WordPress
etc etc
# END WordPress
Would be grateful for any advice. =>
Place the following in the .htaccess for the domain
# .htaccess WildCard SSL + wordpress + subdomain
RewriteEngine on
RewriteCond %{HTTP_HOST} ^shop.domain.com$
RewriteCond %{REQUEST_URI} !^/shop/
RewriteRule ^(.*)$ /shop/$1
RewriteCond %{HTTP_HOST} ^shop.domain.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(/)?$ shop/index.php [L]
# BEGIN WordPress for main domain
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^index\.php$ - [L]
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I want to install WordPress in subdirectory and remove index.php in permalinks.
The server is IIS 6.0, support rewrite.
My webserver has the following directories:
webroot
--wp [wordpress folder]
webroot/.htaccess
RewriteCond %{HTTP_HOST} ^(www\.)?a.luckyet\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/wp/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wp/$1
RewriteCond %{HTTP_HOST} ^(www\.)?a.luckyet\.com$ [NC]
RewriteRule ^(/)?$ wp/
webroot/wp/.htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f #1
RewriteCond %{REQUEST_FILENAME} !-d #2
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] #3
It works when I visit a.luckyet.com and a.luckyet.com/hello-world.html
But it does not work when I visit a.luckyet.com/wp-login.php or a.luckyet.com/wp-admin
The #3 works fine, but #1 and #2 can not work properly. Then I saw here and change the content of webroot/wp/.htaccess to:
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
It still does not take effect. Can anyone help me? Thanks in advance!
Update:
ISAPI_Rewrite version is 3.0.
All code in webroot/.htaccess:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?a.luckyet\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/wp/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wp/$1
RewriteCond %{HTTP_HOST} ^(www\.)?a.luckyet\.com$ [NC]
RewriteRule ^(/)?$ wp/
All code in webroot/wp/.htaccess:
RewriteEngine on
# For file-based wordpress content (i.e. theme), admin, etc.
RewriteRule wp-(.*) wp-$1 [L]
# For normal wordpress content, via index.php
RewriteRule ^/$ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f #1
RewriteCond %{REQUEST_FILENAME} !-d #2
RewriteRule (.*) index.php/$1 [L]
Wordpress permalink is:
/%postname%.html
Thus, Wordpress can work fine when visit http://a.luckyet.com/ or http://a.luckyet.com/hello-world.html
Question:
If there is a real file like a.html in webroot/wp/, like webroot/wp/a.html, wordpress 404 error will be reported when visit http://a.luckyet.com/a.html, . How can I fixed this?
You're dynamically rewriting the URLs with the .htaccess file and WordPress settings to tack on the .html extension - any files that are "real-life" .html files are being handled upstream by the IIS Handler Mappings.
You'll have to update your Handler Mappings in IIS for .html files especially to direct the requests directly to the physical file.
I am trying to redirect a wordpress blog from an old domain to a new domain and changing the structure of the urls on the new domain.
So I want www.domainA.com to redirect to test.domainB.com/folder/
and www.domainA.com/2001/12/some-post to redirect to test.domainB.com/folder/some-post
This is what I currently have in my htaccess file. I have managed to achieve my second objective, but if you go to www.domainA.com, it does not redirect to test.domainB.com/folder/ All the other pages redirect properly aside from the homepage.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domainA\.com$ [NC]
RewriteRule ^([0-9]+)/([0-9]+)/(.*)$ http://test.domainB.com/folder/$3 [R=301,NC,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I am sure I am missing something elemetary, but I can't seem to figure it out :(
Try this code :
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domainA\.com$ [NC]
RewriteRule ^/?\d+/\d+/(.*)$ http://test.domainB.com/folder/$1 [NC,L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?domainA\.com$ [NC]
RewriteRule ^/?$ http://test.domainB.com/folder/ [NC,L,R=301]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /index.php [L]