Use .htaccess for friendly URLs

I read many similar questions, but could not change the URL for a SEO friendly name. This is strange because I believe that my requirement should be simple. Therefore, I am going to be specific in the hope of knowing what I am missing. I do my testing on the local computer before I hosted it on the server.

Here is what I got:

http://localhost/ggs2/forms/mymain.php 

That's what i want

 http://localhost/ggs2/goals 

In the ggs2 subdirectory, I have a .htaccess file that states:

 Options +FollowSymLinks RewriteEngine On RewriteRule ^/goals$ /forms/mymain.php 

When I click on the target link, the URL has not been changed.

So:

  • Is there a problem with the .htaccess file?
  • Is there some kind of server setup I need to install?
  • Something else?

thanks

+6
source share
1 answer

try the following:

 RewriteRule ^goals/?$ /forms/mymain.php [NC,L] 

The first slash is removed, which means that you were looking for the root folder, not the current folder.

+11
source

Source: https://habr.com/ru/post/900262/


All Articles