/    Sign up×
Community /Pin to ProfileBookmark

a couple of Mod Rewrite .httaccess problems

Origional problem below semi sorted

im using [CODE]([A-Za-z0-9-]+)[/CODE] in my mod rewrite rules to select any characters in the part of the url

such as if i have a code like

[CODE]^magic-tricks/([A-Za-z0-9-]+)[/CODE]

it will redirect any folder name in urls such as

[CODE]http://www.mysite.com/magic-tricks/anyfoldername[/CODE]

but what if my folder name has 1 or more hyphens in the name

how can i make the [CODE]([A-Za-z0-9-]+)[/CODE] detect any number of hyphens and treat them as text aswell so the above example would work even if they fodler name had 5 hyphens in it, without me having to create a rule for each possible combination of text-text-text or text-text etc

[QUOTE]

cant seem to find a solution and i have looked but nothing seems to be working

im using the following

[CODE]# Begin search engine friendly links code
Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteRule ^magic-tricks/([A-Za-z0-9-]+)-([A-Za-z0-9-]+)-([A-Za-z0-9-]+)-([A-Za-z0-9-]+)-([A-Za-z0-9-]+).htm$ magic-tricks-$1-$2-$3-$4-$5.php
RewriteRule ^magic-tricks/([A-Za-z0-9-]+)-([A-Za-z0-9-]+)-([A-Za-z0-9-]+)-([A-Za-z0-9-]+).htm$ magic-tricks-$1-$2-$3-$4.php
RewriteRule ^magic-tricks/([A-Za-z0-9-]+)-([A-Za-z0-9-]+)-([A-Za-z0-9-]+).htm$ magic-tricks-$1-$2-$3.php
RewriteRule ^magic-tricks/([A-Za-z0-9-]+)-([A-Za-z0-9-]+).htm$ magic-tricks-$1-$2.php
RewriteRule ^magic-tricks/([A-Za-z0-9-]+).htm$ magic-tricks-$1.php
RewriteRule ^magic-tricks$ magic-tricks.php

RewriteRule ^articles/([A-Za-z0-9-]+)-([A-Za-z0-9-]+)-([A-Za-z0-9-]+)-([A-Za-z0-9-]+)-([A-Za-z0-9-]+).htm$ articles-$1-$2-$3-$4-$5.php
RewriteRule ^articles/([A-Za-z0-9-]+)-([A-Za-z0-9-]+)-([A-Za-z0-9-]+)-([A-Za-z0-9-]+).htm$ articles-$1-$2-$3-$4.php
RewriteRule ^articles/([A-Za-z0-9-]+)-([A-Za-z0-9-]+)-([A-Za-z0-9-]+).htm$ articles-$1-$2-$3.php
RewriteRule ^articles/([A-Za-z0-9-]+)-([A-Za-z0-9-]+).htm$ articles-$1-$2.php
RewriteRule ^articles/([A-Za-z0-9-]+).htm$ articles-$1.php
RewriteRule ^articles$ articles.php[/CODE]

Im using this ro re write page names for a certain folder (imaginary) to the php file that has the same name as you cans ee

2 problems, firstly none of them actually work except the ones that Rewrite the main folder name tro the main php file, such as folder magic-tricks Rewriting to magic-tricks.php

and also when people add a trailing slash to the folder name it comes up with 404 error

what am i doing wrong, is there anyway to simplify the above code so i dont have to have so many lines for files with different amounts of words hyphenated in file name instead of having one line for each different amount of hyphens in the file name

i need this working asap and i know its something simple as i have gotten it working before on another site but now it wont, and im using same host and same method as the other one

[/QUOTE]

Solved it for now thanks

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@bokehDec 18.2006 — Post some example URIs.
Copy linkTweet thisAlerts:
@BWWebDesignsauthorDec 18.2006 — thanks anyway but i actually have that problem sorted now i stumbled upon the answer myself by accident and its seems to work

thanks
×

Success!

Help @BWWebDesigns spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...