2

I have come across a problem, where my whole web-project is under a subdirectory of a subdirectory in my web server, therefore the 'public_html' folder in there does not fall off from the URL.

Is there a way to do this strip via .htaccess in a clean way?


Here is an example of my URL structure:

http://myurl.domain.com/portfolio/projects/MyProject/public_html/?page=home

I would also like to perform some cleaning to my URL by stripping off the ?page= parameters, but I'm running a PHP config with an array which sets the <title> of the current page by identifying the current parameter in use with $_GET.

Second question is; can I strip those parameters off or will that break my title-setup and if I can and it will not break anything, how am I supposed to do it?


Thanks in advance, I'm a total newbie when it comes to .htaccess and any help and advice granted I will hoard to my knowledge!

Pepelius
  • 1,576
  • 20
  • 34

1 Answers1

1

In your root htaccess file ,try adding this :

RewriteEngine On
RewriteCond %{THE_REQUEST} /portfolio/projects/MyProject/public_html/\?page=([^\s]+) [NC] 
RewriteRule ^ /portfolio/projects/MyProject/%1? [NC,R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?portfolio/projects/MyProject/([^/]+)/?$ /portfolio/projects/MyProject/public_html/?page=$1 [QSA,L,NC]

This will redirect "/portfolio/projects/MyProject/public_html/?page=pagename" to "/portfolio/projects/MyProject/pagename" stripping out the public_html folder and querystrings.

Amit Verma
  • 40,709
  • 21
  • 93
  • 115
  • Thanks for your answer, however this seems to create some sort of a problem here, for my URL is now the following: `http://myurl.domain.com/portfolio/projects/MyProject/?portfolio/projects/` Any idea on what could be wrong? I tried to change the .htaccess file location to the root of my 'portfolio' -folder, but this did not make a change. Firsthand try was that the .htaccess file was located in the 'MyProject' folder. **I can not use the root folder of the web server, therefore I have to put it under the project folder or my portfolio, if that matters.** – Pepelius Aug 19 '15 at 08:30
  • Got it figured out! And thanks for Mikko in guidance for RewriteBase, this helped. – Pepelius Aug 21 '15 at 08:55