简体   繁体   中英

How to rewrite/change url using javascript

I know this has already been answered, but mine is somehow special.

Firstly, my site is not a PHP site (it's an XHTML site).

So, can someone teach me how to rewrite url like this:

mysite.com/forum2_theme_CATEGORY-ID.xhtml?n=PAGE-ID&tema=TOPIC-ID 

To something like:

mysite.com/forum2/CATEGORY-ID/TOPIC-ID/PAGE-ID

Please note that my site is not a PHP site, it's just an XHTML site.

I will be happy if I can get a suitable solution.

Thanks.

You will have to get your hands a bit dirty with Apache mod_rewrite. There's lots of good tutorials for beginners:

http://www.sitepoint.com/guide-url-rewriting/

you also might be able to find an existing examples of similar rewrite rules to yours as your case is pretty standard

If you want to change the url you can use: window.history.pushState("", "", '/newpage'); But it's not the proper way to build a website.

I don't understand how are you creating a forum without using any server site language like PHP. I suggest to use a framework like ZendFramework(PHP), Spring(Java), ExpressJS, etc. Instead of modifying the mod_rewrite.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM