.htaccess WP-admin url twice - php

I am unable to access my WordPress site URL, it redirects like
http://www.mydomain.net/wp-login.php?redirect_to=http%3A%2F%2Fmydomain.net%2Fmydomain.net%2Fwp-admin%2F&reauth=1
but it shoud redirect to
http://www.mydomain.net/wp-login.php?redirect_to=http%3A%2F%2Fmydomain.net%2Fwp-admin%2F&reauth=1
I believe the problem is with .htaccess file as I am rewriting the path of folder like
public_html/mydomain.net
instead of public_html as this domain is primary domain of cPanel but to avoid confusing, I created a directory and rewriting path using .htaccess.
There is nothing wrong with WordPress. In settings>general both the URLs set to mydomain.net
.htaccess code is Placed in Public_HTML
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain.net$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.mydomain.net$
RewriteCond %{REQUEST_URI} !mydomain.net/
RewriteRule (.*) /mydomain.net/$1 [L]

I had a similar problem after changing the root directory of my blog (before migration) and trying to coming back... Changing the data in my DB was not working for me.
I still did not figure out why but I had a "page not found" when I tried to access categories, tags,... and even on the home page. Links to articles worked correcly and the administration page was not accessible (wp-admin rewritten twice in the url).
These actions solved my problem:
Edit the wp-config.php file.
After the "define" statements (just before the comment line that says "That's all, stop editing!"), insert a new line, and type:
define('RELOCATE',true);
Save your wp-config.php file.
Open a web browser and manually point it to wp-login.php on the new server.
I had to change the value of the root directory in the administration page (after these actions gave me back the access to it).
Check http://codex.wordpress.org/Changing_The_Site_URL#Relocate_method for more info.

Related

htaccess with wordpress inside subdirectory

i've a simple question but i cant find and answer for that:
i have in my site-root folder 3 subdirectory, in the first one i have a wordpress site, in the second and in the third two other sites but only for testing like this:
domain.com/wordpress/
domain.com/test1/
domain.com/test2/
Now i want when the user goes on the site to redirect him on my wordpress site but also when i want to access the other sites i directly put the correct address and go.
Right now i have the code down below but, when i try to connect to other folder he redirect me to the 404 wordpress page. How should i edit it to make it works?
I also want if its possible when i go on wordpress to not show the subdirectory in the url but only the domain:
NOT -> domain.com/wordpress/index.php
BUT -> domain.com/index.php
RewriteEngine On #created by aruba do not touch this file!
RewriteCond %{REQUEST_URI} !(.*)wordpress
RewriteRule ^(.*)$ wordpress/$1 [L]

Pathing issues when I try to set my .htaccess file to my main file location. (cpanel)

I'm trying to set up the base path/file for my site on my server. The file I want to load is in my document root within the following path:
/src/pages/views/index.php
I'm trying to get my .htaccess file to point to this location by default. I have tried doing this
DirectoryIndex /src/pages/views/index.php
which does automatically route to my index file, but then all relative paths in my site no longer work. (My url bar shows just 'mywebsite.com')
If I don't have anything in my .htaccess file, then I go to mywebsite.com (which shows me the root directories) and manually click my way into the directory that I want, everything works just fine and there are no pathing issues (my url bar now shows 'mywebsite.com/src/pages/views/').
By "pathing issues", I mean all of my imported files (javascript, css, etc) are 404ing because it can't find the path.
Is there a way to actually make it so that when a user types in :
mywebsite.com
it will actually redirect them to the proper path? :
mywebsite.com/src/pages/views/
Give this a try:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mywebsite.com$ [NC]
RewriteRule ^(.*)$ http://www.mywebsite.com/src/pages/views/$1 [R=301,L]
You can also try:
RewriteEngine on
RewriteRule ^mywebsite\.com$ /mywebsite.com/src/pages/views/?&%{QUERY_STRING}

Wordpress url rewrite on subdirectory

I have a wordpress install which has only two custom post types ( blog and howto ).
The blog is located in a directory inside root folder where also are few html pages, like this :
To access a certain custom post type from html files i have an href to wp/blog and another one to wp/howto.
The problem is that i want to jump that wp so my url will be like localhost/blog instead localhost/wp/blog.
I tried with
RewriteEngine On
RewriteRule blog/ /wp/blog/
RewriteRule howto/ /wp/howto/
in .htaccess from root directory, it shows me the blog template, but only 404 page error and i have no idea what should i modify to get the wordpress posts.
PS : Sorry for my english and for my blurry message, deadline's coming and i have no idea what should i do to skip that folder.
1) in your dashboard, go to settings -> general and make sure
a) wordpress directory -> http://mydomain.com/wp
b) site address -> http://mydomain.com
2) move your index.php from subdirectory to the root (MOVE, don't just copy)
3) edit your index.php to read
/** Loads the WordPress Environment and Template */
require('./wp/wp-blog-header.php');
where "wp" is your subdirectory
4) delete any .htaccess file in the subdirectory
5) add this to your .htaccess in the root
# 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
Under this setup, your wordpress installation will be located in /wp/ directory. Visitors will visit your site using http://mydomain.com.
If you want to have a good read-up on everything so you know exactly what you're doing, read this https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
If i understand you correctly - all the wordpress system files are inside the "wp" folder.
if that is the case all you need to do is to drag them out to the main folder and the problem would be fixed by itself.
As far as the post types (blog/howto) if those are post types inside the wordpress system the are not effected by real folders but by something call Wildcard DNS - which is a method of linking url's to content by values inside the url. this means that the folder does not have to exist inside the server but just in the system.
For solving your issue i recommend to just, as i said before - drag all the files from inside the folder "wp" - outside of it.
And after that you will need to log in to the database with phpmyadminor any other client you have and go to:
A) choose wp_options
B) Look option_name for siteurl and remove the "wp" from the url. (if it's http://sample.com/wp change it to http://sample.com)
C) Look option_name for home and do the same.
Edit:
Try this:
in your root directory (the parent of "wp"), open the .htaccess file and add inside mod_rewrite.c:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?YourDomain.com$
RewriteRule ^(/)?$ wp [L]
change the YourDomain.com to your real domain.
this should work :)
source: ~here~
im looking for a solution just like this. People keep on going around the question. What you want is for the custom posts to look like they come from the route mysite.com/todo/have-a-nice-day mysite.com/blog/todo/instead of mysite.com/blog/

Redirect directory to subdomain cpanel

Alright I have already contacted BlueHost Support and they couldn't figure out how to fix this issue. I've also tried to use cpanels 301 permanent redirect but that doesn't work so I decided to give it a whirl on here.
I host with BlueHost.com if you haven't caught that by now. The file structure is as follows:
public_html/
directory1/subdomaindirectory
directory2
directory3
I have my main website in my root (public_html). Then I have to create new directories and assign the url to that directory. So essentially if you typed in www.maindomain.com/directory1 it would show the website in the directory. I would like to modify the .htaccess to redirect that to it's original domain so www.maindomain.com/directory1 would go to www.directory1.com
The same for subdomains. I created subdomain.directory1.com and pointed it to public_html/directory1/subdomaindirectory and if you go to www.directory1.com/subdomain it pulls up the site.
I realize theoretically it's the same thing but it bugs me that you are able to pull up a website like that.
Is there anyway to modify the .htaccess to fix this issue?
In.htaccess you could do it like this
RewriteEngine On
RewriteBase /gorbox
RewriteCond %{HTTP_HOST} ^www.gorbox.com$ [NC]
RewriteRule ^support$ http://support.gorbox.com [L,R=301]
Put this in the .htaccess file that resides within the root folder of www.gorbox.com

Inherited PHP site not finding assets

I've inherited a PHP site from another developer and can't quite figure out what's going wrong. I'm suspecting some kind of rewrite rule somewhere but Im not sure where to look (or what specifically to look for...)
I've installed MAMP and it is working fine. I've got a couple sites running in the MAMP directory with no problems.
When I drop this site in and try to run the pages, I get pages with no CSS, JavaSCript or images. When I 'right-click' an image and open it in a new tab the image can't be found because the browser tries to go up one level in the directory to the MAMP directory in stead of looking in the site root directory.
Same thing on links to other pages, they all try to go up to the MAMP htdocs directory.
For example in htdocs I have the root folder of my site with the index page: 'htdocs/mysite.com/index.php'
On the page is a link to another page <li class="nav_company">Company
Clicking on 'Company' causes the browser to go up to the htdocs folder and look for the '/company/index.php', which of course doesn't exist.
Where do I go looking for the culprit on this? Is there a term or something I can search the site files for? I'm using dreamweaver and cold utilize the find and replace tool if I just knew what to go looking for...
Edit Here's the (sanitized) .htaccess file in the root folder of the site
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^sitename\.com
RewriteRule (.*) http://www.sitename.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ http://www.sitename.com/$1 [R=301,L]
Redirect 301 /products/ http://www.sitename.com/plastic-handles/
Redirect 301 /plastic/index.html http://www.sitename.com/plastic/plastic.html
Redirect 301 /applicator/index.html http://www.sitename.com/applicator/applicators.html
Redirect 301 /company/index.html http://www.sitename.com/company/about-us.html
Redirect 301 /contact/index.html http://www.sitename.com/contact/contact-us.html
Redirect 301 /news/index.html http://www.sitename.com/news/news.html
Redirect 301 /trade/index.html http://www.sitename.com/trade/tradeshows.html
Thanks in advance.
It would seem that your assets and links are all pointing to the root so /contact/index.php will look at http://localhost/contact/index.php instead of http://localhost/mysite.com/contact/index.php
Look into setting up a virtual host to point to the new sites directory.
Otherwise it would be a case of changing all the links and assets to the full URL e.g. http://localhost/mysite.com/contact/index.php
Hope this helps
Edit: here is a guide to setting up a virtual host http://sawmac.com/mamp/virtual/
Edit 2: in response to your edit, .htaccess isn't going to make a difference as when you click a link or the server looks for an asset it's going to be looking in htdocs/. It will go no further and therefore will not reach your .htaccess.

Categories