Author Topic: Need some mod_rewrite help  (Read 745 times)

0 Members and 1 Guest are viewing this topic.

Offline The Alchemist

  • Peasant
  • *
  • Posts: 100
  • Cookies: 18
  • Cult Of Personality
    • View Profile
    • Scriptings - Paste Tool
Need some mod_rewrite help
« on: June 12, 2013, 12:48:36 pm »
I want to do some mod_rewrite on my site. But, I'm new to using .htaccess
I want to change the URL
http://scriptings.tk/paste/viewcode.php?id=5190da909e5b1
to
http://scriptings.tk/paste/5190da909e5b1

So that whenever a user requests
http://www.scriptings.tk/paste/<id>

The result of
http://www.scriptings.tk/paste/viewcode.php?id=<id>
is displayed...
Where <id> is an alphanumeric string.

Will this be the sufficient and working mod_rewrite code ?
Code: [Select]
RewriteEngine On
RewriteRule ^paste/([^/]*)$ /paste/viewcode.php?id=$1 [L]
And do I just need to add this to my .htaccess of my server thats located in public_html folder?
« Last Edit: June 12, 2013, 01:09:49 pm by The Alchemist »
Defeat the best... To be the best...

Offline Stackprotector

  • Administrator
  • Titan
  • *
  • Posts: 2515
  • Cookies: 205
    • View Profile
Re: Need some mod_rewrite help
« Reply #1 on: June 12, 2013, 12:56:19 pm »
First be sure that you can indeed use .htaccess (witch is in fact a override).


EDIT:
try deny from all
« Last Edit: June 12, 2013, 12:56:44 pm by Factionwars »
~Factionwars

Offline The Alchemist

  • Peasant
  • *
  • Posts: 100
  • Cookies: 18
  • Cult Of Personality
    • View Profile
    • Scriptings - Paste Tool
Re: Need some mod_rewrite help
« Reply #2 on: June 12, 2013, 01:03:12 pm »
First be sure that you can indeed use .htaccess (witch is in fact a override).


EDIT:
try deny from all
I tried using the above code that I posted.
When I make the .htaccess file and add the code to it, both the URLs http://scriptings.tk/paste/viewcode.php?id=5190da909e5b1
as well as
http://scriptings.tk/paste/5190da909e5b1
are displaying 404 errors.

So, does this mean its usable?
« Last Edit: June 12, 2013, 01:09:13 pm by The Alchemist »
Defeat the best... To be the best...