Help Needed for rewrite URL

Alles, was den Apache betrifft, kann hier besprochen werden.

Help Needed for rewrite URL

Postby rit_netsys » 04. May 2015 05:46

Hi,

First of all, I am not into Linux (never worked before) or into Apache. Basically I am .NET developer. Due to some wired situation, I need to set up a site in CentOS . After lot of studies & trial - error method, I have managed to host the site in working condition as follows -

http://Server_IP:8000

As per client requirements, all files has been kept on custom location - /home/mydl/apps/layers_v1/htdocs . There are lots of PHP files here (named as data_A1.php, data_a2.php and so on).After changing few settings & PATH variables, I could able to open the site as below -

http://Server_IP:8000/layers_v1/htdocs/data_a1.php

Above mentioned URL types are working very fine. But now customer has given another requirement. Whenever a user calls "http://Server_IP:8000/layers_v1/htdocs/data_a1.php" , he/she should see "http://Server_ip/a1.php".

After lots of googling, I think, this may be done with .htaccess / httpd.conf file. As I am very new with Linux & Apache, I could not able to understand the details properly. I tried to write following lines on .htaccess file, but it didn't work.

RewriteEngine on
RewriteBase /layers_v1/htdocs/
RewriteRule data_(.*)?$ /$1 [L]

Can anyone help me out to fix this issue?? It will be very helpful for me.
Please note that am not into Linux or administration part.
rit_netsys
 
Posts: 3
Joined: 04. May 2015 05:23
Operating System: CentOS 6.6

Re: Help Needed for rewrite URL

Postby Nobbie » 04. May 2015 10:36

rit_netsys wrote:Whenever a user calls "http://Server_IP:8000/layers_v1/htdocs/data_a1.php" , he/she should see "http://Server_ip/a1.php".


What exactly is meant by that? The user enters "http://Server_IP:8000/layers_v1/htdocs/data_a1.php" and then

a) he should be redirected to "http://Server_ip/a1.php" (the URL changes in the Browser)?

b) he should only get the contents of "http://Server_ip/a1.php", but the URL in the browser remains "http://Server_IP:8000/layers_v1/htdocs/data_a1.php"?


Anyway, is Server_ip from one URL the same value as Server_IP from the other URL?
And did you omit the Port 8000 accidently or is there listening a server on Port 80? Not applying a Port automatically results in Port 80.

If there also listens a Server on Port 80, why did you use Port 8000 instead?

FInally, this is a very strange issue; i would expect it just vice verse: the User must only enter "http://Server_ip/a1.php" in his browser and the Server shows up the contents of "http://Server_IP:8000/layers_v1/htdocs/data_a1.php" - that would be understable, as it provides nice URLs for the User. But vice verse i cannot see any sense.

What actually happens, if the User enters "http://Server_ip/a1.php"?
Nobbie
 
Posts: 8772
Joined: 09. March 2008 13:04

Re: Help Needed for rewrite URL

Postby rit_netsys » 04. May 2015 10:43

Hi,
Thanks nobbie for your reply ..
its my mistake, I did not mention. Actually I need Point-A that u mentioned. Content should be displayed as "http://Server_IP:8000/layers_v1/htdocs/data_a1.php" but user will see "http://Server_ip/a1.php" (the URL changes in the Browser) in browser.
We used port 8000 as per customer requirements. They don't want to use Port-80. Don't know why.
rit_netsys
 
Posts: 3
Joined: 04. May 2015 05:23
Operating System: CentOS 6.6

Re: Help Needed for rewrite URL

Postby Nobbie » 04. May 2015 10:52

rit_netsys wrote:Hi,
Thanks nobbie for your reply ..
its my mistake, I did not mention. Actually I need Point-A that u mentioned. Content should be displayed as "http://Server_IP:8000/layers_v1/htdocs/data_a1.php" but user will see "http://Server_ip/a1.php" (the URL changes in the Browser) in browser.
We used port 8000 as per customer requirements. They don't want to use Port-80. Don't know why.


If there is no Server listening on Port 80, this issue is technical impossible. It cannot be solved. You cannot replace the requested URL by a "fake URL". You only can offer to enter a fake URL and show up the contents of an existing URL. But this also limited to the fact, that there MUST be a server listening on Port 80.

P.S.: Again, this is a very very strange request, are you sure that you got it right from your customer? I have never seen a similar behaviour in the internet and i cannot find any use for it.
Nobbie
 
Posts: 8772
Joined: 09. March 2008 13:04

Re: Help Needed for rewrite URL

Postby rit_netsys » 11. May 2015 12:31

Hi Nobbie once again...

We discussed with our customer and now they agreed to work with Port - 80. Can you help me on the rest part ??
rit_netsys
 
Posts: 3
Joined: 04. May 2015 05:23
Operating System: CentOS 6.6

Re: Help Needed for rewrite URL

Postby Nobbie » 11. May 2015 13:54

rit_netsys wrote:We discussed with our customer and now they agreed to work with Port - 80. Can you help me on the rest part ??


If the "rest part" remains as before, it is still impossible (even if you can use Port 80):

You cannot replace the requested URL by a "fake URL".



Finally, this board is not intended for professional help (probably your customer pays for your service), as it is based on voluntary help from private to private people. It is not a professional support plattform.
Nobbie
 
Posts: 8772
Joined: 09. March 2008 13:04


Return to Apache

Who is online

Users browsing this forum: No registered users and 5 guests