I am trying to re-write the URL of one file. I want thankyou.php to show up as /thank-you/. I have gotten this to work only partially.

I have this one rule in my htaccess file:

RewriteEngine On
RewriteRule    ^thank-you/?$    thankyou.php    [NC,L]

I can get this to work for domain.com/thank-you but NOT for domain.com/thank-you/

For some reason the last slash is not working.

Can anyone help me out with this..??

Thank you in advance.

有帮助吗?

解决方案

Yes, the relative links are broken.

Your relative links are broken because the browser sees the URL http://example.com/thank-you/, so all relative links will resolve to the base /thank-you/ (e.g. /thank-you/styles/mystyle.css).

Change all your links to absolute URLs or add a relative URI base to the header of your pages:

<base href="/" />

其他提示

Question mark at the end of your rule says, that this last character is optional. Did you try to use:

RewriteEngine On
RewriteRule ^thank-you\/$ thankyou.php [NC,L]
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top