Am I misunderstanding what RewriteCond does?

To explain to those who come upon this page:

We can use an .htaccess file to show SEO-friendly names in internal links to open links in your directory that are SEO non-friendly links.

Example:
If I have this SEO-friendly internal link on my page:
< p>< a href="**testing.html**">test< /a>< /p>

… and this rule in .htaccess in the same directory as index.html (testing.html does not actually exist as a file):
_ RewriteRule ^ testing.html$ index.html [L]

… then the server will respond to clicking by pulling index.html, but will show testing.html in the browser URL box.

I thought there was a way to show an SEO-friendly URL in the browser URL window in place of the non-friendly URL. This is the way it is done!

NOTE: make sure that scripts do not depend on the name of the file, or they won’t run. (One of my page’s slideshow JS detection scripts plays depending on the name of the file. The RewriteRule changes the file to testing.html and that name and the old name needs to be in the script to keep it working.)

Following example for .htaccess file – internal link “Home-Page-Announcements.html” will open the file named “index.html” that’s listed in your directory:

Options +FollowSymLinks 
RewriteEngine On
RewriteRule ^Home-Page-Announcements.html$ index.html [L]

^ = start matching URL pattern here
$ = stop matching URL pattern here
[L] = if the rule matches, stop looking

1 Like