Reputation: 153
I have a page with an url like this:
https://example.net:9000/something
I want to be able to access it from here https://example.net/mysite
and mask the url as well so it will always show everything like this before the last /
I tried like this:
RewriteRule ^:9000/something/?$ /mysite/
but it didnt work. Why?
also, I have some other rules on my htaccess that have to stay unaltered:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(jpeg|jpg|gif|png)$ /public/404.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L] <---everything up to this point has to stay the same
RewriteRule ^:9000/something/?$ /mysite/
</IfModule>
Thank you.
Upvotes: 0
Views: 45
Reputation: 42935
https:/example.net/
and https://example.net:9000
hare two separate http hosts that have nothing to do with each other. So you'd actually need the server for https:/example.net/
to proxy requests meant to be relayed to https://example.net:9000
.
Assuming that https:/example.net/
is served by an apache http server (due to how you ask your question), this should be possible using the apache proxy module, either directly:
ProxyRequests off
ProxyPass /mysite/ https://example.com:9000/something/
ProxyPassReverse /mysite/ https://example.com:9000/something/
( Yes, indeed ProxyRequests off
and not on
if you implement this in the central server configuration. Leave that line away if you only have access to dsitributed configuration files (".htaccess") )
... or via the rewriting module:
RewriteEngine on
RewriteRule ^/?mysite/(.*)$ https://example.com:9000/something/$1 [P]
For that the proxy module and the proxy_http modules have to be loaded in the http server, obviously. The rule has to be implemented in the configuration of the http host serving https:/example.net/
. If you do not have access to that you can instead implement it in the distributed configuration file (typically called ".htaccess") located in the DOCUMENT_ROOT
of that host.
Upvotes: 1