This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-11-09 10:59:44

technoboy10
Scratcher
Registered: 2007-08-25
Posts: 1000+

Htaccess regex

Can you do something like this in RegEx (for htaccess)?
/page1/something that renames to /page1?id=something


So long, 1.4.
http://goo.gl/3JEV9

Offline

 

#2 2012-11-09 11:29:52

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Htaccess regex

From memory:

Code:

RewriteEngine On
RewriteBase /

RewriteRule ^/page1/([A-z]+)/?$ page1?id=$1
# adjust the [A-z] part as necessary, if you need more characters
# Actually maybe replace it with \w?

Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#3 2012-11-09 11:33:13

technoboy10
Scratcher
Registered: 2007-08-25
Posts: 1000+

Re: Htaccess regex

Thanks!


So long, 1.4.
http://goo.gl/3JEV9

Offline

 

#4 2012-11-09 17:10:52

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Htaccess regex

judging from what it's supposed to translate into, you're probably going to want numbers in the expression too.

so the search string should be
^/page1/([aìzAìZ0ì9]+)/?$
or, for any character,
^/page1/(.*)$

Offline

 

#5 2012-11-09 19:55:13

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Htaccess regex

LS97 wrote:

judging from what it's supposed to translate into, you're probably going to want numbers in the expression too.

so the search string should be
^/page1/([aìzAìZ0ì9]+)/?$
or, for any character,
^/page1/(.*)$

\w matches digits.


nXIII

Offline

 

#6 2012-11-10 06:00:12

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Htaccess regex

nXIII wrote:

LS97 wrote:

judging from what it's supposed to translate into, you're probably going to want numbers in the expression too.

so the search string should be
^/page1/([aìzAìZ0ì9]+)/?$
or, for any character,
^/page1/(.*)$

\w matches digits.

But it seemed to me that \w is not what was used.

Offline

 

#7 2012-11-10 10:42:28

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Htaccess regex

LS97 wrote:

nXIII wrote:

LS97 wrote:

judging from what it's supposed to translate into, you're probably going to want numbers in the expression too.

so the search string should be
^/page1/([aìzAìZ0ì9]+)/?$
or, for any character,
^/page1/(.*)$

\w matches digits.

But it seemed to me that \w is not what was used.

blob8108 wrote:

From memory:

Code:

RewriteEngine On
RewriteBase /

RewriteRule ^/page1/([A-z]+)/?$ page1?id=$1
# adjust the [A-z] part as necessary, if you need more characters
# Actually maybe replace it with \w?

nXIII

Offline

 

#8 2012-11-10 10:55:06

technoboy10
Scratcher
Registered: 2007-08-25
Posts: 1000+

Re: Htaccess regex

Hmm... It didn't work. I also couldn't get my clean URL rename to work in the directory that the htaccess is in.


So long, 1.4.
http://goo.gl/3JEV9

Offline

 

#9 2012-11-10 11:15:19

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Htaccess regex

technoboy10 wrote:

Hmm... It didn't work. I also couldn't get my clean URL rename to work in the directory that the htaccess is in.

You have to change "RewriteBase /" to the directory you want…


nXIII

Offline

 

#10 2012-11-10 11:56:11

technoboy10
Scratcher
Registered: 2007-08-25
Posts: 1000+

Re: Htaccess regex

nXIII wrote:

technoboy10 wrote:

Hmm... It didn't work. I also couldn't get my clean URL rename to work in the directory that the htaccess is in.

You have to change "RewriteBase /" to the directory you want…

Oh, okay.  tongue


So long, 1.4.
http://goo.gl/3JEV9

Offline

 

#11 2012-11-10 12:13:37

technoboy10
Scratcher
Registered: 2007-08-25
Posts: 1000+

Re: Htaccess regex

Okay, now page1/something goes to some page with no CSS and when I var_dump $id (I used $_GET), it gives me NULL.


So long, 1.4.
http://goo.gl/3JEV9

Offline

 

#12 2012-11-10 13:12:46

XenoK
Scratcher
Registered: 2011-09-08
Posts: 1000+

Re: Htaccess regex

well you could have a bunch of issues here.  I'm going to assume you are using php for your extension.

Code:

RewriteEngine On
RewriteBase /
RewriteRule ^page1/(.*)$ page1.php?id=$1

try that.  I got rid of a lot of unnecessary slashes.


Eternity Tasks has launched into Alpha One! http://tasks.eternityincurakai.com/EI%20projects.png

Offline

 

Board footer