2

there's probably a very simple answer to my question, but after hours of browsing I still haven't found a solution, so thank you very much for all your help. Perhaps I should mention that I'm using a subdomain with Bluehost (multiple domains on the same account).

I would like to rewrite: www.example.com/myfolder to www.example.com/index.php?s=myfolder

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ /index.php?s=$1 [L]
  • example.com/abcd -> works
  • example.com/abcd/ -> works but destroys my picture URLs
  • example.com/abcd/index.php -> doesn't work (redirects me to main page)

Thank you very much for your help. Roland

2 Answers2

0

Have you checked this: https://aloneonahill.com/blog/url-rewriting-for-beginners

and: URL rewriting with PHP

RewriteEngine on RewriteRule ^/?Some-text-goes-here/([0-9]+)$ /picture.php?id=$1

OutstandingBill
  • 2,614
  • 26
  • 38
0

To rewrite to index, use:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)/?$ /index.php?s=$1 [L]

And for css, scripts, or pictures, use absolutes links (which begin with / or http://...) or add <base href="/"> in html head.

Croises
  • 18,570
  • 4
  • 30
  • 47