Reputation: 3261
It took me 2 hours but I can't figure it out and I don't know how to google a solution.
This is my Rewrite-Rule in the .htaccess-file:
RewriteCond %{REQUEST_URI} ^/blog(.*)
RewriteRule ^(.*) http://localhost:2368/$1 [P]
When I call example.com/blog, it should redirect me to my blog. The blog is a ghost-blog running in nodejs (port 2368).
This would work when I use no condition. So I can see the main site of my blog at example.com.
http://example.com/xy => http://localhost:2368/xy
But with the condition and the rule, it seems like this happens:
http://example.com/blog/xy => http://localhost:2368/blog/xy
But I don't want it to redirect to http://localhost:2368/blog/xy. It sould redirect to http://localhost:2368/xy.
How can I solve this problem?
Upvotes: 1
Views: 155
Reputation: 40434
The rule you're looking for is:
RewriteCond %{REQUEST_URI} ^/blog/(.*)
RewriteRule ^blog/(.*) http://localhost:2368/$1 [P]
The $1
comes from the RewriteRule
statement, not from RewriteCond
. So $1
contained blog/xy
instead of just xy
You can check the Rule working in here: .htaccess tester
Upvotes: 1