Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use with WP site .htaccess #9

Open
davids701124 opened this issue Jul 18, 2015 · 1 comment
Open

How to use with WP site .htaccess #9

davids701124 opened this issue Jul 18, 2015 · 1 comment

Comments

@davids701124
Copy link

Hi thanks for making this useful plugin.

I tried to use this with my WP site. My WP site install in the root and Yourls installed in the subfolder. When I use this together. For example, if I make google.com to mysite.com/g. The shorten url will be point to WP's 404 page. I think it's because this line

RewriteRule . /index.php [L]

I tried to comment it out, the shorten url will work. However, all links on my site won't work anymore. For example

mysite.com/about
mysite.com/works/01

I'm not an expert for .htaccess configuration. Could you guide me is there a way to make this work. How should I rewrite the rule? Thank you.

The original .htaccess is following

# 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
# BEGIN YOURLS

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([0-9A-Za-z]+)/?$ http://mysite.com/yourl/yourls-go.php?id=$1 [L]
RewriteRule ^([0-9A-Za-z]+)\+/?$ http://mysite.com/yourl/yourls-infos.php?id=$1 [L]
RewriteRule ^([0-9A-Za-z]+)\+all/?$ http://mysite.com/yourl/yourls-infos.php?id=$1&all=1 [L]

# END YOURLS
@BorysekOndrej
Copy link

Hi there.
Quite some time ago, I have encountered a similar issue. I am hosting YOURLS on subdomain, but with little changes it should also work for folder on main domain. This is the relevant part of my .htaccess to your question.

RewriteEngine On
## BEGIN YOURLS     
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^links.mysite.net
    RewriteRule ^([0-9A-Za-z]+)\+/?$ http://links.mysite.net/$1+ [L]     

    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([0-9A-Za-z]+)/?$ http://links.mysite.net/yourls-go.php?id=$1 [L]
    RewriteRule ^([0-9A-Za-z]+)\+/?$ http://links.mysite.net/yourls-infos.php?id=$1 [L]
    RewriteRule ^([0-9A-Za-z]+)\+all/?$ http://links.mysite.net/yourls-infos.php?id=$1&all=1 [L]
# END YOURLS

# BEGIN WordPress
    RewriteBase /
    RewriteRule ^index\.php$ - [L]

    # add a trailing slash to /wp-admin
    RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteCond %{HTTP_HOST} !^domains.mysite.net [NC]
    RewriteRule ^ - [L]
    RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
    RewriteRule ^(.*\.php)$ $1 [L]
    RewriteRule . index.php [L]
# END WordPress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants