2

I've trying to rewrite my URL's but doesn't work as expected. This

RewriteRule ^([^/]*)/$ /index.php?currentpage=$1 [L]
should rewrite
http://site/index.php?currentpage=2 to-> http://site/2/

but nothing happen is still http://site/index.php?currentpage=2. Also this

RewriteRule ^([^/]*)/$ /page.php?pn=$1 [L]
should rewrite http://site/page.php?pn=2 to-> http://site/2/

This brake whole site and cause error 500

Any idea why and what is wrong?

Jason Paddle
  • 1,118
  • 1
  • 15
  • 32

1 Answers1

1

I've used links like this to go on next or prev page

// Prev page
<a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'>

// Next page
<a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>

I didn't understand it right at first and tryed to make changes only in .htaccess file but then I've read that there is no way to happen if I don't change also hrefs so I've change them like this

// Prev page
<a href='/currentpage/$prevpage/'>

// Next page
<a href='/currentpage/$nextpage/'>

in .htaccess file I put this

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^currentpage/([^/]*)/$ /index.php?currentpage=$1 [L]

and now when I change pages is like http:/website.com/currentpage/2/

Please correct me if there is something else that is wrong but so far is working as expected. Thank's for help!

UPDATE

I've forget about that when I've made this changes I've made also changes on path to my style.css and other images/js etc. files. What I mean is before I used to include style.css this way <link rel="stylesheet" type="text/css" href="include/style.css"> after change the urls in order to get proper path must add one lead slash (/) so it become <link rel="stylesheet" type="text/css" href="/include/style.css">. Also added to other elements..

Jason Paddle
  • 1,118
  • 1
  • 15
  • 32