Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: [Solved] Different redirection when using different domain |
|
Author |
|
avielfadida
Joined: 13 Sep 2014 Posts: 1 Location: Israel
|
Posted: Sat 13 Sep '14 16:28 Post subject: [Solved] Different redirection when using different domain |
|
|
Hello everyone, first let me say I'm using Apache/2.4.10 (Win32).
I have a problem when using mod_rewrite, let me describe a scenario:
I have 1 domain and 1 subdomain:
1. example.com
2. m.example.com
Both point to the same ip address.
As many websites do I want my posts will appear for example as:
example.com/Article-Name
So I decided to use the following rewrite rule to do so:
Code: |
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/([a-z-]+)/?$ [NC]
RewriteRule ^ %{REQUEST_SCHEME}://%{SERVER_NAME}/?title=%1 [L]
|
The above 3 lines are used inside .htaccess file, the .htaccess file is placed inside my root folder.
When I'm viewing the website via example.com as expected there is internal redirection to example.com/?title=Article-Name, I won't be able to see the change in my url bar, I will see something like example.com/Article-Name/.
But when I'm viewing the website via m.example.com there is external redirection and I will see m.example.com/?title=Articl-Name/.
I have no idea why the behavior is different, if anyone can explain I will be very thankful.
Let me say that I did find a solution:
Code: |
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/([a-z-]+)/?$ [NC]
RewriteRule ^ /?title=%1 [L]
|
My problem is that I don't understand why the first rule:
Code: |
RewriteRule ^ %{REQUEST_SCHEME}://%{SERVER_NAME}/?title=%1 [L]
|
couldn't work, and even worse I don't know how the solution is even solving my problem.
I got my answer here: http://serverfault.com/questions/628240/apache-htaccess-url-rewrite
this topic can be closed. |
|
Back to top |
|
|
|
|
|
|