0

I have site setup in wordpress as root folder like /wordpress and one angular site setup in sub folder /wordpress/angular.

Currently if user visits url like mydomain.com/wordpress/sample-page, it displays wp page and if visits like mydomain.com/wordpress/angular/#/sample-page or mydomain.com/wordpress/angular/#/parent-page/child-page, it displays angular page.

After #/, whatever it is, it should stay on angular page. Currently it is staying, but angular in url should not be shown

I want to remove angular from url if user visits angular page.

So, I put .htaccess file in wordpress folder like this

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteCond %{REQUEST_URI} !(.*)angular
RewriteRule ^(.*)$ angular/$1 [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>

Now if I visit url like mydomain.com/wordpress/#/any-url, it should stay on angular' page but not working.

I guess I need to check if url contains #, then make it redirect to angular folder. As it is a special character, how to make some condition on above code.

I am taking ref from

https://stackoverflow.com/questions/6795134/htaccess-rewrite-url-remove-subdirectory

https://stackoverflow.com/questions/3220377/htaccess-redirect-if-url-contains-a-certain-string

I am not much expert on htaccess config. So any help will be appreciated.

  • 3
    You can't check for # in .htaccess. The fragment identifier (after the #) is client side only. It is never sent to the server. Only your JavaScript can see it. – Stephen Ostermiller Oct 1 at 14:16
  • any other way around to hide angular from url ? – Hiranya Sarma Oct 1 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.