1

I have this link:

<a href="admin.php?page=buyingreport">Buying Report</a>

To get a pretty URL, I've changed it to:

<a href="admin/buyingreport">Buying Report</a>

And this is my whole .htaccess:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^mysite [nC]
RewriteRule ^/?$ "http\:\/\/www\.mysite\.com\/" [R=301,nC]

RewriteRule ^([^/.]+)$ $1.php [L]

RewriteRule ^admin/([a-z]+)$ admin.php?page=$1 [L]

I always get 404 Not Found error "The requested URL /admin/buyingreport.php was not found on this server". Why was it redirect me to buyingreport.php?

The .htaccess file doesn't seem to work. Is there anything wrong with it? Or maybe with my link?

Anybody can help me, please?

Iam
  • 13
  • 3

1 Answers1

0

This works perfectly

RewriteEngine On
RewriteRule ^admin/([a-zA-Z0-9]+)$ admin.php?id=$1 [QSA]
Mourad karoudi
  • 89
  • 1
  • 11
  • It doesn't work. It still direct me to buyingreport.php. What I want is get this URL: www.mysite.com/admin/buyingreport. While my actual page URL is: www.mysite.com/admin?page=buyingreport. – Iam Jun 06 '16 at 10:02
  • change the variable **id** with **page** `RewriteRule ^admin/([a-zA-Z0-9]+)$ admin.php?page=$1 [QSA]` – Mourad karoudi Jun 06 '16 at 10:34
  • if still doesn't work.check this answer maybe the problem from httpd.conf [link](http://stackoverflow.com/questions/17162214/htaccess-not-working-on-localhost-with-xampp) – Mourad karoudi Jun 06 '16 at 10:59
  • Yes it works now. There is a little problem with js and css. But it's ok I'll find the answer. Thanks. – Iam Jun 06 '16 at 14:45
  • Great. the problem is come from the url because the url show like the content in a folder. to fix it just add this code before you closing `` change the http://maintarget/ with you your own main target. – Mourad karoudi Jun 06 '16 at 14:54