logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

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.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Rewrite Rule to Hiding Sub Folder
Author
jponnusamy



Joined: 30 May 2016
Posts: 12
Location: Qatar, Doha

PostPosted: Mon 30 May '16 12:24    Post subject: Rewrite Rule to Hiding Sub Folder Reply with quote

Dear All,
I am new to Apache, We have requirement to hide subfolder from User View, but internally it should point & work. Kindly please help on this. and sorry for my bad english.

Current URL:
Code:
http://cmspweb1.com/sites/en_US/xxxx
Expecting URL:
http://cmspweb1.com/sites/xxxx


Current URL:
Code:
http://cmspweb1.com/sites/fr_CA/xxxx
Expecting URL:
http://cmspweb1.com/sites/fr/xxxx


I did the Following on Apache HTTP, URL is getting Change for fr_CA, but getting 404 Error. For en_US, Nothing is working.

Code:

RewriteRule ^/sites/fr_CA/(.*) http://cmspweb1.com/sites/fr/$1
RewriteRule ^/sites/en_US/(.*) http://cmspweb1.com/sites/$1


I tried Lot but nothing is working. Kindly please help me on this
Thanks
Jay Crying or Very sad
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Sun 05 Jun '16 18:39    Post subject: Reply with quote

You forgot the rewrite flags at the end the lines. Else several rules are applied to the url.

Code:
RewriteRule ^/sites/fr_CA/(.*) http://cmspweb1.com/sites/fr/$1 [P,L]
RewriteRule ^/sites/en_US/(.*) http://cmspweb1.com/sites/$1 [P,L]


Maybe you don't need the P tag. See https://httpd.apache.org/docs/current/rewrite/flags.html for that.
Back to top
jponnusamy



Joined: 30 May 2016
Posts: 12
Location: Qatar, Doha

PostPosted: Mon 06 Jun '16 8:14    Post subject: Reply with quote

Dear James,

Thanks for your reply. But still its not getting 404 Errors only. We have these modules, can you please let us know if we missed any modules or Libraries to make it work?
Code:

mod_headers.so
mod_jk.so
mod_proxy.so
mod_proxy_ajp.so
mod_proxy_http.so
mod_rewrite.so
mod_vhost_alias.so


Thanks
Jayaram
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Thu 16 Jun '16 18:43    Post subject: Reply with quote

Did you enable the engine with RewriteEngine on ?
Back to top
jponnusamy



Joined: 30 May 2016
Posts: 12
Location: Qatar, Doha

PostPosted: Sun 19 Jun '16 8:08    Post subject: Reply with quote

Hi James,

Attached my virtualHost conf file, Kindly please let me know whether if something wrong in the entry.

Code:
<VirtualHost *:80>
   ServerName cmspweb1

    ErrorLog logs/del/http_error.log
    RewriteLog logs/del/http_rewrite.log
    CustomLog "|/opt/apps/apache/bin/rotatelogs -f  /opt/apps/apache/logs/del/http_access.log.%Y.%m.%d 86400 +60" imi

    RewriteEngine on

      RewriteCond %{REMOTE_ADDR} !^000\.000\.000\.000$
      DocumentRoot /opt/apps/docroot
      RewriteRule ^/+$ /sites/  [R,L]
      
      RewriteRule ^/sites/fr_CA/(.*) http://cmspweb1.com/sites/fr/$1 [P,L]
      RewriteRule ^/sites/en_US/(.*) http://cmspweb1.com/sites/$1 [P,L]

    <IfModule rewrite_module>
      Options +FollowSymlinks
      RewriteEngine    On
      RewriteOptions Inherit
      RewriteLog logs/rewrite.log
   </IfModule>
   JkMount   /*        del_svr
JkOptions +ForwardURICompatUnparsed
</VirtualHost>


Thanks
Jayaram
Back to top


Reply to topic   Topic: Rewrite Rule to Hiding Sub Folder View previous topic :: View next topic
Post new topic   Forum Index -> Apache