wecodemore / wpstarter

Easily bootstrap whole site Composer packages for WordPress.
https://wecodemore.github.io/wpstarter/
MIT License
246 stars 35 forks source link

Hide /wp/ in admin URL? #15

Closed GaryJones closed 4 years ago

GaryJones commented 9 years ago

With WP core inside /wp/, the admin URLs become prefixed with /wp/. While this could be changed to /app/or /admin/, is there a way to just hide it altogether? Perhaps include steps for .htaccess rewrite?

gmazzap commented 9 years ago

I don't want to include steps for .htaccess because it makes sense only for Apache users.

I myself often use Nginx, and there are a lot of other web servers out there.

Moreover, I want to make WP Starter as more flexible as possible: things that can independendly set by users without affecting functionality, should be allowed, without forcing anything that is not necessary.

For this reason I don't want to remove that part of the url by defaut (it can be already customized based using wordpress-install-dir in composer.json.

IMO, a documentation entry in readme / web site is enough for me, and who cares can remove that part of the url using the method allowed by their web server software.

franz-josef-kaiser commented 9 years ago

@GaryJones for Nginx it should be around the lines

location /wp {
     rewrite ^/wp(/.*)$ $1 last;
}

With Apache and mod_rewrite enabled, it should be something like

RewriteEngine ON
RewriteRule ^wp(/.*)$ $1 [L,QSA]
GaryJones commented 9 years ago

Thanks. Documentation on the website would be sufficient.

franz-josef-kaiser commented 9 years ago

@GaryJones Just file a pull request for that, please :)

GaryJones commented 9 years ago

Is your code above definitely correct? As that's what I'll blindly include in the PR :-)

franz-josef-kaiser commented 9 years ago

@GaryJones just out of my mind, the other half from a highly upvoted answer on SO. Please test that upfront.

franz-josef-kaiser commented 8 years ago

No idea why I closed this – maybe I assumed that @GaryJones would file either a PR or open another issue?

grappler commented 7 years ago

I tried the nginx rule but it did not work but I found one that does

rewrite ^/(wp-.*.php)$ /wp/$1 last;
rewrite ^/(wp-(content|admin|includes).*) /wp/$1 last;

https://wordpress.stackexchange.com/questions/138648/nginx-rules-for-subdomain-multisite-install-bedrock

schlessera commented 7 years ago

Hey @grappler, Thanks for providing these!

I have two questions:

  1. In the link you've posted, there's a third rule that comes before the ones you've posted, which looks like it is adding a trailing slash to /wp-admin. Is that not needed in your case?
  2. Did you need to adapt .env or wp-config.php for these to work?
grappler commented 7 years ago

In the link you've posted, there's a third rule that comes before the ones you've posted, which looks like it is adding a trailing slash to /wp-admin. Is that not needed in your case?

I was running it on VVV and that rule was already there.

Did you need to adapt .env or wp-config.php for these to work?

I just changed both site and home url to be the same without wp at the end. You can either make this change in the wp-config.php with the constants or change the values in the database.

grappler commented 7 years ago

I might as well add what I use for apache too. This is part of the whole WordPress rewrite rules.

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) wp/$1 [L]
RewriteRule ^(.*\.php)$ wp/$1 [L]
RewriteRule . index.php [L]
gmazzap commented 6 years ago

In v3 we have optional steps... maybe after some tests it is the case to add a step that does this.

lkraav commented 6 years ago

In v3 we have optional steps... maybe after some tests it is the case to add a step that does this.

@gmazzap is v3 branch safe enough to try using in production already?

https://github.com/wecodemore/wpstarter/projects doesn't seem to list v3 with any due date indication, so not sure how far things are or aren't.

gmazzap commented 6 years ago

@lkraav no it is not yet ready. It is heavily in development and during the same day could bè broken several times. I will merge into "dev" when I'll be confident it will be ready for tests in the wild.

lkraav commented 5 years ago

Did this issue become resolved by v3 beta?

gmazzap commented 5 years ago

There's no issue :) We need to document how to obtain this, not sure yet where/how. I'm not 100% sure it fits the main documentation.

dnaber-de commented 4 years ago

Just drop that here: I use these rewrite rules which also fits for multisite configurations with path segments as part of site-urls: https://github.com/inpsyde/wpstarter-boilerplate/blob/master/templates/.htaccess.example Never had any issues with these on several projects.

gmazzap commented 4 years ago

Documented here: https://github.com/wecodemore/wpstarter/blob/dev/docs/03-WordPress-Integration.md#admin-url

Closing.

Thanks you all, expecially @dnaber-de