Change URL in localhost (.htaccess)

Asked

Viewed 756 times

0

I would like to change the URL of my local server. I use XAMPP.

I believe it is necessary to create or change the .htaccess. Actually, I already created the file and put it in the root of localhost, that is, in the directory htdocs.

I would like to make the following amendment:

Of: http://localhost/src/php/studies/

To: http://localhost/studies/

That is, I would like to remove the directories /src/ and /php/ of the URL. Could you help me?

I didn’t understand the other posts similar to this one. I’m not sure, but to change the . htaccess it takes a notion of Regex that I lack.

Printscreen dos diretórios

Thank you!

1 answer

0


Richard, good morning.

Try the following at the root of htdocs, you need to create a . htaccess and place the code.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ src/php/$1 [L]

Comment if it worked.

  • The page is in basic HTML. Probably because mine css style. is in another directory, right? I posted the structure of the subdirectories of the htdocs. In fact, when I click on any of my browsing links between the pages of the site, the URL still remains. Directories disappear only if I type, for example, http://localhost/start. The tags are directed as follows <a href="/start">Home</a>, <a href="/studies">Bible Studies</a> etc.

  • Try to exchange the last line for that Rewriterule (.*). html$ src/php/$1 [L,R=301]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.