DO NOT DEAL WITH THIS MEMBER
Jan 27, 2017 05:45 AM
(This post was last modified: Jan 27, 2017 05:48 AM by Skidy.)
Dont know where to put this other than here. If its in the wrong section please just tell me.
So I am trying to rewrite www.mysite.com/view.php?code=ANY_LETTER_OR_NUMBER
to www.mysite.com/view/ANY_LETTER_OR_NUMBER
This rewrties my .php to just /view/
PHP Code
<?php RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^(.*)$ $1.php
How can I do this?
This is what I have currently:
RewriteRule ^view/(.+)$ /view.php?code=$1 [L,QSA]
Doesnt work
http://stackoverflow.com/questions/12138...ual-folder
This should help you somewhat, i never made it look like a directory before. For a shortener i worked on i used this:
RewriteRule ^(\w+)$ filename.php?id=$1
It just left with the id/num but without the directory.
DO NOT DEAL WITH THIS MEMBER
(Jan 27, 2017 10:45 PM)Yani Wrote: Is this your whole file? Maybe you have something above that rule that fires first?
Yeah its my whole file. Want it to take a directory under view.
DO NOT DEAL WITH THIS MEMBER
(Jan 28, 2017 04:14 AM)Yani Wrote: You have to add this above the ruleset:
I have that on already. Still doesn't work.
Any ideas??
DO NOT DEAL WITH THIS MEMBER
(Jan 28, 2017 04:45 AM)Yani Wrote: Maybe look at your apache access log?
Should this work then?
Code RewriteRule ^view/(.+)$ /view.php?code=$1 [L,QSA]
Jan 29, 2017 04:49 PM
(This post was last modified: Jan 29, 2017 04:50 PM by NoSuchAgency.)
Try this
Code RewriteEngine On
RewriteRule ^view/([^/]*)\.php$ /view.php?code=$1 [L]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
DO NOT DEAL WITH THIS MEMBER
Jan 29, 2017 05:44 PM
(This post was last modified: Jan 29, 2017 05:47 PM by Skidy.)
(Jan 29, 2017 04:49 PM)NoSuchAgency Wrote: Try this
Code RewriteEngine On
RewriteRule ^view/([^/]*)\.php$ /view.php?code=$1 [L]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
It works but all of my code is gone weird.
https://hisky.space/view/car
Look at that URL. It makes the page lose some of its HTML.
It seems to break here:
https://gyazo.com/103134b68a235d29acc0b14fbebd5265
Hmm weird. It shouldn't be doing that. I am at work but I'll be home again in 4 hours to give a better look. If you send me the source code (or rather access to the server) I'll see what's up
DO NOT DEAL WITH THIS MEMBER
(Jan 29, 2017 06:03 PM)NoSuchAgency Wrote: Hmm weird. It shouldn't be doing that. I am at work but I'll be home again in 4 hours to give a better look. If you send me the source code (or rather access to the server) I'll see what's up
Brilliant, thank you. Ill send it now
Try turning the [L] to [L,QSA]
DO NOT DEAL WITH THIS MEMBER
Jan 29, 2017 06:06 PM
(This post was last modified: Jan 29, 2017 06:07 PM by Skidy.)
(Jan 29, 2017 06:05 PM)NoSuchAgency Wrote: Try turning the [L] to [L,QSA]
https://gyazo.com/920a32cc409197471998ae013b037dc1
Get a 500 error now.
(Jan 29, 2017 06:05 PM)NoSuchAgency Wrote: Try turning the [L] to [L,QSA]
Thank you btw, I send my code over.
|